This is my text in side of a UIButton:
It should says "highscores", but it is okay now since it is in Storyboard and not running. My constrains are as followed:
The proportional width is 0.3 of the superview. I settled this in my viewDidLoad:
highscoresButton.titleLabel!.minimumScaleFactor = 0.5
But the simulator shows exactly the same as the storyboard. When applying a minimum scale factor for UILabels it works correctly. What am I doing wrong here? Thank you. Changing the minimum scale factor to 0.1 has also no effect.
Buttons are a little quirky... This won't change it in Storyboard without some effort turning it into a custom IBDesignable control, but should get where you want at runtime.
btn.titleLabel!.font = UIFont(name: "Your Font", size: 50.0)
btn.titleLabel?.minimumScaleFactor = 0.1
btn.titleLabel?.numberOfLines = 1
btn.titleLabel?.adjustsFontSizeToFitWidth = true
btn.titleLabel?.lineBreakMode = NSLineBreakMode.byClipping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With