Type Method 型メソッド

periodic(from:by:)

A schedule for updating a timeline view at regular intervals.

Declaration 宣言

static func periodic(from startDate: Date, by interval: TimeInterval) -> PeriodicTimelineSchedule
Available when Self is PeriodicTimelineSchedule.

Parameters パラメータ

startDate

The date on which to start the sequence.

interval

The time interval between successive sequence entries.

Discussion 議論

Initialize a TimelineView 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 PeriodicTimelineSchedule.Entries structure to return the sequence of dates when the timeline view calls the entries(from:mode:) method.

See Also 参照

Getting Built-in Schedules