iosfontsautolayoutuilabelconstraints

How do I change the font size according to screen size


I have added min font size to label but the font is not changing according to the screen size.

I thought setting min font size and using autolayout is to scale the label height is enough.

But its not happening.


Solution

  • Use minimum font scale instead of minimum font size. Minimum font size was deprecated in IOS 6. In the image although mine says fixed here you can change that and then set the scale factor.

    To vary by size of the screen you can do some of that with interface builder. See image. This is using size classes. AddFontSize

    Other ways would be to increase the font size to a large number and let it scale, set it in code by device type, or set a constraint on the label to make it grow and shrink between different sizes and have the scaling set right.