Autoshrink setting for UIButton in Storyboard

Evol Gate picture Evol Gate · Mar 8, 2016 · Viewed 11.2k times · Source

There is a setting for UILabel in storyboard that allows setting auto-shrink configurations, as shown below:

enter image description here

But I am unable to find the same for UIButton's textlabel. I am aware that I can set this programmatically but curious to know if there's a way to enable this setting for UIButton in Storyboard.

Answer

Nicholas picture Nicholas · Mar 22, 2016

You can use User Defined Runtime Attributes to set this flag using the storyboard.

Set the following key path:

titleLabel.adjustsFontSizeToFitWidth to true

Adjust Font Size using Storyboard