Set UILabel's font size to fit its frame size?

I have an application that allows the user to use the pinch gesture to scale the label. How do I change the font size to fit the new frame size so that the font just fits into the rectangle of the frame?

My current step only sets the label with the new transformation, and the text will look blurry if the label is scaled too small / large. I want the label to be able to clearly display text where the text can have a maximum size according to the new rectangle of the frame.

+8
ios uilabel uifont
source share
1 answer
myLabel.adjustsFontSizeToFitWidth = YES; 

If you are using InterfaceBuilder, check the "Autoshrink" box for the label.

Make sure the "Minimum Size" is not too large.

+35
source share

All Articles