WidgetKit: .timer Text style expands it to fill the width, instead of taking space to fit the contained string

Viewed 251

.timer Text style expands it to fill the width, instead of taking space to fit the contained string. Is there a way to change this behavior?

Text(entry.timeFinished, style: .timer).multilineTextAlignment(.leading).opacity(0.5).background(Color.red)

enter image description here

Text("3:41").opacity(0.5).background(Color.blue)

enter image description here

Entire View:

struct TimePieceWidgetEntryView: View {
    
    var entry: Provider.Entry
    
    var body: some View {
        VStack {
            Text("Timer ⏱")
            Text(Date().addingTimeInterval(600), style: .timer).opacity(0.5)
        }.font(.title.bold().monospacedDigit())
        .padding(5)
        .widgetURL(entry.url)
    }
    
}
1 Answers

Simple solution:

HStack(alignment: .top) {
    Text("03:00")
    Spacer()
}
Related