Autoshrink setting for UIButton in Storyboard

Viewed 12682

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.

5 Answers

Swift 4 solution

class CustomButton : UIButton{
    @IBInspectable var adjustsTitleFontSizeToFitWidth: Bool = false {
        didSet {
            self.titleLabel?.adjustsFontSizeToFitWidth = adjustsTitleFontSizeToFitWidth
        }
    }
}
extension UIButton {
    @IBInspectable var adjustsTitleFontSizeToFitWidth: Bool = false {
        didSet {
            self.titleLabel?.adjustsFontSizeToFitWidth = adjustsTitleFontSizeToFitWidth
        }
    }
}
Related