How to determine width needed for a button in SwiftUI

260 Views Asked by At

If I have a string that I will place inside of a SwiftUI button label, how can I determine how much width I need to allow the button to consume such that the text in the button will not be truncated with ellipsis?

This would assume no font size modifier is applied and would take into account the current Dynamic Type size preference.

1

There are 1 best solutions below

0
On

The fixedSize modifier as mentioned by Asperi works for this.