How it works
DefaultDateProgressLabel is the view SwiftUI synthesizes to describe the current value of a timer-driven ProgressView. When you create a ProgressView over a date range and omit your own current-value label, the framework supplies this type to render the remaining time as a live, relative date that ticks down on its own. It exists so that countdown and elapsed-time indicators read out a sensible "time remaining" string for free, keeping date-based progress visually and verbally in sync without any per-second bookkeeping on your part.
Drive progress from a date range with ProgressView(timerInterval:)
The timer-interval initializer takes a ClosedRange<Date> and fills the bar as the clock moves from the lower to the upper bound. DefaultDateProgressLabel is the current-value label SwiftUI attaches to that ProgressView automatically; in the example the range
intervalruns fromDate()toDate().addingTimeInterval(60), giving a sixty-second countdown.Let the default label fill in the time-remaining text
Because the example supplies only a leading
Label("Countdown", systemImage: "timer")and no explicit current-value label, SwiftUI inserts DefaultDateProgressLabel for you. It formats the distance to the range's end as a relative date and refreshes it as the interval advances, so the countdown updates without a Timer or any state of your own.Pair it with a progress view style
DefaultDateProgressLabel composes with whatever style the ProgressView adopts. Here
.progressViewStyle(.linear)draws a horizontal bar, and the synthesized date label is laid out alongside it; switching the style repositions the same label rather than changing what it reports.Override it only when you need custom value text
Reach for DefaultDateProgressLabel implicitly whenever the stock relative-time readout is good enough. If you need different wording or formatting, provide your own current-value label closure to the timer-interval initializer, and SwiftUI uses that in place of the default.
Date().addingTimeInterval(60) to Date().addingTimeInterval(3600) and watch DefaultDateProgressLabel switch from a seconds-style readout to an hour-scale time-remaining string.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct DefaultDateProgressLabelDemo: View {
private let interval = Date()...Date().addingTimeInterval(60)
var body: some View {
VStack(spacing: 16) {
Text("Timer ProgressView")
.font(.headline)
ProgressView(timerInterval: interval) {
Label("Countdown", systemImage: "timer")
}
.progressViewStyle(.linear)
}
.padding()
}
}