SystemFormatStyle
enum · iOS 18.0+ · SDK 27.1
enum SystemFormatStyleA collection of format styles for displaying live-updating time information in text views. Use the format styles in this namespace to present time-based data in ``Text`` views that automatically updates as the system clock advances. Each style formats a <doc://com.apple.documentation/documentation/foundation/date> value into an <doc://com.apple.documentation/documentation/foundation/attributedstring> and conforms to both `FormatStyle` and ``DiscreteFormatStyle``, allowing SwiftUI to efficiently schedule text updates at exactly the right moments. You typically use these styles with the ``Text/init(_:format:)-8sfgg`` initializer: ```swift let startDate = Date.now let endDate = startDate.addingTimeInterval(300) Text(.currentDate, format: .offset(to: startDate)) // Output: "3 minutes, 42 seconds" Text(.currentDate, format: .stopwatch(startingAt: startDate)) // Output: "00:03.42" Text(.currentDate, format: .timer(countingDownIn: startDate..<endDate)) // Output: "4:17" Text(.currentDate, format: .reference(to: endDate)) // Output: "in 5 minutes" ``` ## Choosing a Style | Style | Purpose | Example Output | |-------|---------|---------------| | ``SystemFormatStyle/DateOffset`` | Elapsed time since or until a date | `3 minutes, 42 seconds` | | ``SystemFormatStyle/Stopwatch`` | Precision stopwatch counting up | `00:03.42` | | ``SystemFormatStyle/Timer`` | Countdown or count-up within a bounded interval | `4:17` | | ``SystemFormatStyle/DateReference`` | Natural-language reference to a date | `in 5 minutes`, `yesterday` |
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
No declarations were skipped in this snapshot.