Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the current font size from an auto shrinking UILabel [duplicate]

Tags:

ios

uilabel

fonts

I've got a UILabel with font size set to 24.0. I've configured it so that it can autoshrink the font size down to a minimum of 12.0. When I get the font from the label, it says it is 24.0, even though that's not the size it is using to actually display the text.

How can I get what font size it is really using?

Note: I'm not asking how to draw the text, the text is already visible in a UILabel.

like image 231
Kenny Wyland Avatar asked Nov 10 '22 13:11

Kenny Wyland


1 Answers

From what I know, you can't actually get it directly, but you can use the sizeWithFont:minFontSize:actualFontSize:lineBreakMode: method to compute it. But be aware that the method is deprecated in iOS 7 and that Apple discourages using a variable font size for labels, because it doesn't provide a consistent experience to the user.

Hope that helps :)

like image 66
Marius Constantinescu Avatar answered Nov 15 '22 05:11

Marius Constantinescu