How do I handle iPhone 6S Plus's font size?

2019-04-23 13:01发布

问题:

iPhone 6S Plus's screen is very big compared to other screen sizes. I can't seem to find a good way to handle the font size of a label without adjusting the size programmatically.

How can I adjust the font size of a label so that it looks smaller on an iPhone 5 and bigger on an iPhone 6 Plus?

回答1:

Don't change font sizes for the iPhone 6 or iPhone 6+.

People buy these phones to see more content. The 6+ displays things slightly bigger than the other phones anyway (yes, it has bigger pixels, not just more pixels), and if a user wants an even bigger display they can switch the whole phone to zoom mode (both 6+ and 6; this turns a 6+ into a large 6, and a 6 into a large 5).

Just use autolayout to position things relative to the screen size.



回答2:

You can't target iPhone 6 Plus using AutoLayout because it's not meant for hardcoding sizes. You either need to use code and do something like this:

if UIScreen.mainScreen().bounds.size.width == 375 {
    // iPhone 6
    label.font = label.font.fontWithSize(20)
}

or just create a invisible view and set top and bottom constraints to it.



回答3:

I think it is better to use adaptive fonts (here is an example, section Adaptive Fonts)