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

2019-04-23 12:31发布

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?

3条回答
我想做一个坏孩纸
2楼-- · 2019-04-23 13:14

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楼-- · 2019-04-23 13:17

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

查看更多
Luminary・发光体
4楼-- · 2019-04-23 13:20

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.

查看更多
登录 后发表回答