UIButton - How to set Minimum Font Size?

in Swift 4/5

Please make sure that yourBtn is available in @IBoutLet, not in action
in viewdidLoad or viewWillAppear

override func viewDidLoad() {
    super.viewDidLoad()
    yourBtn.titleLabel?.numberOfLines = 1
    yourBtn.titleLabel?.adjustsFontSizeToFitWidth = true
    yourBtn.titleLabel?.lineBreakMode = NSLineBreakMode.byClipping
}

Anoop's answer works like a charm. You can also do this in IB using User Defined Runtime Attributes:
- choose Button in IB
- Add Attribute
- KeyPath: titleLabel.adjustsFontSizeToFitWidth
- Type: Boolean
- Value: true
Screenshot from IB


button.titleLabel.numberOfLines = 1;
button.titleLabel.adjustsFontSizeToFitWidth = YES;
button.titleLabel.lineBreakMode = NSLineBreakByClipping;

copied from Set minimum font size UIButton with margin


Set Minimumfontsize is not available in iOS8 use minimumscalefactor instead.