5

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.

Xu Yin
  • 3,932
  • 1
  • 26
  • 46
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • possible duplicate of [How to figure out the font size of an UILabel when -adjustsFontSizeToFitWidth is set to YES?](http://stackoverflow.com/questions/2396715/how-to-figure-out-the-font-size-of-an-uilabel-when-adjustsfontsizetofitwidth-is) and http://stackoverflow.com/questions/6606998/uilabel-and-getting-the-size-after-autofit?rq=1 – rmaddy Feb 12 '14 at 23:30
  • 1
    That is not a duplicate question. It is related question and what's worse is that the answer to the other question is deprecated in iOS7. I don't need to measure my text, I need to find out what font size my existing label is using. Not the same. – Kenny Wyland Feb 27 '14 at 02:06
  • Ignoring the fact that the other answer uses a now deprecated method, how is it not a duplicate? It answers the question have. If it doesn't, what is different about your question? – rmaddy Feb 27 '14 at 02:11

1 Answers1

1

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 :)