I am attempting to format a timer with the code:
It does indeed work fine for the content, but the text field appears much longer than it should. I want to center this text under another text entry so I used a VStack, but the timer appears left justified and does not align on center based on the content.
If I write my own method to provide just the limited characters I want, I can indeed center it without issue, but this does not countdown once per second for the widget view. I suppose I could get around this by adding 3600 timeline entries for the next hour, but I don't think that would be a great solution.
Is there any way to resolve this? I can kind of get around it by adding a frame that fits for the case of 00:00 or 0:00 but not both.
Code Block Text(Date().addingTimeInterval(2400), style: .timer)
It does indeed work fine for the content, but the text field appears much longer than it should. I want to center this text under another text entry so I used a VStack, but the timer appears left justified and does not align on center based on the content.
If I write my own method to provide just the limited characters I want, I can indeed center it without issue, but this does not countdown once per second for the widget view. I suppose I could get around this by adding 3600 timeline entries for the next hour, but I don't think that would be a great solution.
Is there any way to resolve this? I can kind of get around it by adding a frame that fits for the case of 00:00 or 0:00 but not both.
I asked what I believe to be a similar question yesterday, and a helpful community member indicated that adding the .multilineTextAlignment(.center) modifier was successful in centering the text. I tested this inside of a HStack (as well as a HStack embedded in a VStack and the timer text did appear centered.
I am only finding this issue within a Widget and not similar behavior in a traditional SwiftUI view.
I am only finding this issue within a Widget and not similar behavior in a traditional SwiftUI view.