init(timerInterval:pauseTime:countsDown:showsHours:)
Creates an instance that displays a timer counting within the provided interval.
Declaration
init(timerInterval: ClosedRange<Date>, pauseTime: Date? = nil, countsDown: Bool = true, showsHours: Bool = true)Parameters
- timerInterval:
The interval between where to run the timer.
- pauseTime:
If present, the date at which to pause the timer. The default is
nilwhich indicates to never pause. - countsDown:
Whether to count up or down. The default is
true. - showsHours:
Whether to include an hours component if there are more than 60 minutes left on the timer. The default is
true.
Discussion
Text(
timerInterval: Date.now...Date(timeInterval: 12 * 60, since: .now),
pauseTime: Date.now + (10 * 60))The example above shows a text that displays a timer counting down from “12:00” and will pause when reaching “10:00”.