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

3

8

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?

Bring answered 7/1, 2015 at 20:26 Comment(11)
What does "control its size class" mean? Xcode lets you create constraints that are conditional based on size class. What problem remains? Also, what does "the labels appear messed up" mean? My labels aren't "messed up" on an iPhone 6 Plus, so shouldn't you be asking yourself why yours are?Squires
Thank you for replying my question Matt. The problem is that the size classes you use to control the other iPhone's sizes aren't accurate enough. For example, if I place a label at the top of the UIViewController the same label looks good on a 4 inches iPhone but it doesn't on a iPhone Plus and it needs some resizing. The bad thing is I can't resize it because iPhone 6 Plus hasn't got its own size class therefore I must keep other iPhone's constraints.Bring
Learn how auto layout works.Bolding
Are you telling me there’s a way to target the iPhone 6 Plus in portrait? If so, what's that about? Thanks.Bring
"if I place a label at the top of the UIViewController the same label looks good on a 4 inches iPhone but it doesn't on a iPhone Plus and it needs some resizing. The bad thing is I can't resize it" The size of a label is based on its contents. If its contents don't change, why would it need resizing? Is the problem that you want to resize the font of the label? Then use dynamic text, letting the user resize it, or else change it in code and let the label resize itself in response.Squires
That definitely makes sense, thank you Matt! So I guess my problem is more concerned about the font size, rather than the content inside the label. Is there any way to control the iPhone 6 Plus's font size? I heard someone talking about Auto Shrink but I'm not sure. Thanks!Bring
As I said (badly), if you use Dynamic Type then you can just let the user's preferences deal smoothly with the text size. But you cannot escape having to set the size in code. You can tell if you're on an iPhone 6 plus because it has a triple-resolution screen, which you can easily detect in code.Squires
Thank you again Matt. Please post that comment as an answer and I'd be glad to accept it. Anyway, may I please know how to use Dynamic Type?Bring
what about size classes?Helfand
@CeceXX you have bumped this question again by editing it. But you have already answered and accepted your own answer. No one else is going to add to this. If you'd like a new answer then I'd suggest deleting your answer and adding the code that you have tried into the question.Bolding
@Bolding you're right. I just wanted to make it look like pristine, but you're right when you say there's no point in bumping a question already answered.Bring
A
6

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.

Anticipant answered 3/12, 2015 at 15:16 Comment(1)
"People buy these phones to see more content." such statement is not true omnipotently.Helfand
B
1

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.

Bring answered 22/1, 2015 at 14:43 Comment(1)
This doesn't work in landscape mode. And it breaks if the user chose a large font themselves. And of course it will break if the iPhone 7 is 380 pixels wide.Anticipant
L
1

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

Lashaunda answered 3/12, 2015 at 14:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.