pinglock
pinglock

Reputation: 1253

How to determine width needed for a button in SwiftUI

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.

Upvotes: 0

Views: 331

Answers (1)

pinglock
pinglock

Reputation: 1253

The fixedSize modifier as mentioned by Asperi works for this.

Upvotes: 1

Related Questions