ToB企服应用市场:ToB评测及商务社交产业平台

标题: 【2】Swift Dynamic Island开辟 [打印本页]

作者: 莱莱    时间: 2024-9-7 11:54
标题: 【2】Swift Dynamic Island开辟
灵动岛(Dynamic Island)和实时活动(Live Activities)是 iPhone 为了便于用户在退出APP时,仍然能随时关注进行中的活动、高频操纵的组件。其中:

先新建一个实时活动组件


熟悉下实时活动的代码

  1. struct LiveActivityWidgetAttributes: ActivityAttributes {
  2.     public struct ContentState: Codable, Hashable {
  3.         // Dynamic stateful properties about your activity go here!
  4.         var emoji: String
  5.     }
  6.     // Fixed non-changing properties about your activity go here!
  7.     var name: String
  8. }
  9. struct LiveActivityWidgetLiveActivity: Widget {
  10.                                                                                           
  11. }
复制代码
[code]//
//  ViewController.swift
//  LiveActivity
//
//  Created by yu tian on 2024/7/31.
//

import UIKit
import ActivityKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let state = LiveActivityWidgetAttributes.ContentState(emoji: "




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4