I have an application that allow user to use the pinch gesture for scaling the label How can I change the font size according to the new frame size so that the font just fit in the frame rectangle?
My current step is only set the label with new transform, and the text will look blur if the label is scaled too small/large. I want to ensure that the label can display the text clearly where the text can have the max size according to the new frame rectangle.
To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
Sets the minimum amount that text in this view scales down to fit in the available space.
myLabel.adjustsFontSizeToFitWidth = YES;
If you're using InterfaceBuilder, check "Autoshrink" for the label.
Make sure that "Minimum Size" is not too large.
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