其他分享
首页 > 其他分享> > iOS - SwiftUI 桌面小组件

iOS - SwiftUI 桌面小组件

作者:互联网

1、倒计时

let components = DateComponents(year: 2021, month: 6, day: 10, hour: 12, minute: 0)
let aprilFirstDate = Calendar.current.date(from: components)!

let entry = DayTimeSimpleEntry(date: aprilFirstDate)
entries.append(entry)

let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)

Text(entry.date, style: .timer)
                    .padding()
                    .multilineTextAlignment(TextAlignment.center)
                    .font(.system(size: 20))
                    .foregroundColor(Color.white)

 

标签:entry,桌面,timeline,iOS,let,entries,date,SwiftUI,aprilFirstDate
来源: https://www.cnblogs.com/qiyiyifan/p/14866608.html