根据您提供的时间表更新的视图。
struct TimelineView<Schedule, Content> where Schedule : TimelineSchedule
iOS 15.0+ 测试版
macOS 12.0+ 测试版
Mac 催化剂 15.0+ 测试版
tvOS 15.0+ 测试版
watchOS 8.0+ 测试版
概述
时间线视图就像一个容器,没有自己的外观。相反,它会在预定的时间点重新绘制它包含的内容。例如,您可以每秒更新一次模拟计时器的表面:
TimelineView(PeriodicTimelineSchedule(from: startDate, by: 1)) { context in
AnalogTimerView(date: context.date)
}
创建内容的闭包接收一个类型的输入,您可以使用它来自定义内容的外观。上下文包括触发更新的 。在上面的示例中,时间线视图将该日期发送到您创建的模拟计时器,以便计时器视图知道如何在其脸上画手。TimelineView.Contextdate
上下文还包括一个cadence属性,您可以使用它来隐藏不必要的细节。例如,您可以使用节奏来决定何时适合显示计时器的秒针:
T