SwiftUI Text being truncated when set to resist?

Viewed 700

I have the following component:

Text(booking.endDate!, style: .relative)
                    .font(.system(.title, design: .rounded))
                    .foregroundColor(Color(.jpGreen))
                    .fixedSize(horizontal: true, vertical: false)

This is a countdown to a date formatted as hours and minutes, however in the interface it is randomly truncated at irregular intervals such as this

enter image description here

If i have applied fixed size attributes, how can i go further to make it never truncate?

2 Answers

You can avoid this by adding .allowsTightening(true) to your text.

Applying it may not even fully work depending on just how much space can be tightened.

Source : Mark Moeykens's book

EDIT: Also you can allow SwiftUI to scale your text to fit the available space.

Try using minimumScaleFactor for example, it takes a value between 0 and 1.

How about simply add .padding(.horizontal) to the end just like this.

Text("...").padding(.horizontal)
Related