Is there a way to change the output format of a Text
using init(_ date: Date, style: Text.DateStyle)
?
Using a .timer
, the output is like: 0:42
, but I want something like 00:00:42
.
Background
I want to create a widget (iOS 14) where a timer is running, and as I think it's not a good idea to trigger a widget update every second, and this may even also not work reliably, at least that's not how widget are indented to be used.
So I thought about using this predefined timer functionality of Text
.
I'm quite new to SwiftUI and don't really know about all the capabilities yet. So maybe I could create a similar custom Text-View by myself? Any ideas on how to achieve this?
Or asked differently: Is there a way to create such self-updating components by oneself, that also work in an iOS 14 widget? (Seems like using Timer.publish
to update the View does not work in an iOS 14 widget)