I'm trying to fit the letter '6' inside a UIButton so that the font automatically scales down when the program is run on a small screen device, such that the letter 6 is inside from all sides.
I found several other threads offering solutions to the same problem but for some reason they don't work for me. A few threads I found were:
I have tried the following two code sequences but none gets the job done:
What should I do ?
1:
self.sixButton.titleLabel!.numberOfLines = 0;
self.sixButton.titleLabel!.adjustsFontSizeToFitWidth = true;
self.sixButton.titleLabel!.lineBreakMode = NSLineBreakMode.ByWordWrapping
2:
self.sixButton.titleLabel!.minimumScaleFactor = 0.5;
self.sixButton.titleLabel!.numberOfLines = 0;
self.sixButton.titleLabel!.adjustsFontSizeToFitWidth = true;
3: Same as above but with self.sixButton.titleLabel!.numberOfLines = 1;
.
I'm using Swift 2.2 with Xcode 7.3.1.
A picture of the button at design time:
A picture of the button at run time: