shane
shane

Reputation: 244

Swift 3 Button text auto resizing

So I have buttons that auto resize based on device and I was wondering how I could make the button text resize on its own like a UILable with the minimum size or scale.

Upvotes: 4

Views: 5761

Answers (1)

Sandeep
Sandeep

Reputation: 21154

As Matt said above UIButton title is displayed with UILabel, you could use properties such as minimumScaleFactor and adjustsFontSizeToFitWidth, such that the font resizes based on the size that is available and content that it has.

button.titleLabel.minimumScaleFactor = 0.5;
button.titleLabel.adjustsFontSizeToFitWidth = true;

Upvotes: 9

Related Questions