iosxcodexcode-storyboard

Autoshrink setting for UIButton in Storyboard


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.


Solution

  • 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