UILabel and get size after auto-processing

I have an instance UILabelwith default 28font size and minimum font size 16. I allow the font to automatically adjust to fit this minimum and with only one line.

Suppose I have text in UILabelthat has been automatically adjusted to match. How to get a new font size or, more precisely, a scale factor applied to the content of the label?

[NB. The font property does not change upon auto-detection.]

+1
source share
1 answer

I am afraid that this calculation is done while drawing and is not available (at least using the public apis)

But you should be able to calculate it using one of the methods UIKit sizeWithFont:, for example UILabel. (Beware that text metrics consume a processor ... for example, when using them in a table cell)

+1
source

Source: https://habr.com/ru/post/1526645/


All Articles