The date on which to start the sequence.
periodic(from:by:)
Availability 有効性
- iOS 15.0+
- iPadOS 15.0+
- macOS 12.0+
- Mac Catalyst 15.0+
- tvOS 15.0+
- watchOS 8.0+
Technology
- Swift
UI
Declaration 宣言
static func periodic(from startDate: Date
, by interval: TimeInterval
) -> PeriodicTimelineSchedule
Self
is PeriodicTimelineSchedule
.Parameters パラメータ
startDate
interval
The time interval between successive sequence entries.
Discussion 議論
Initialize a Timeline
with a periodic timeline schedule when you want to schedule timeline view updates periodically with a custom interval:
TimelineView(.periodic(from: startDate, by: 3.0)) { context in
Text(context.date.description)
}
The timeline view updates its content at the start date, and then again at dates separated in time by the interval amount, which is every three seconds in the example above. For a start date in the past, the view updates immediately, providing as context the date corresponding to the most recent interval boundary. The view then refreshes normally at subsequent interval boundaries. For a start date in the future, the view updates once with the current date, and then begins regular updates at the start date.
The schedule defines the Periodic
structure to return the sequence of dates when the timeline view calls the entries(from:
method.