Nan
Nan

Reputation: 534

how to set different font for different screen size, such as iPhone 6s and iPhone SE

I am making a information collection view for my project, I need to indicate a timer inside. How can I set different font size for different screen? Basically, I want to set the font size to 46 in iPhone 6s and the font size is supposed to be 38 in iPhone SE.

enter image description here

Thanks in advance.

Upvotes: 0

Views: 289

Answers (2)

HannahCarney
HannahCarney

Reputation: 3631

Create Macros such as this one that determines that the phone size is 4 or 5:

#define is4sOr5  ([[UIScreen mainScreen] bounds].size.height <= 568.0) ? TRUE:FALSE

//This one does IPAD
 label.font = [UIFont systemFontOfSize:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 12 : 10) weight:.2];
//this one uses MACRO 
 label.font = [UIFont systemFontOfSize:(is4sOr5 ? 12 : 10) weight:.2];

Upvotes: 2

JingJingTao
JingJingTao

Reputation: 1790

You can do this in the interface builder, if you go to the atrributes inspector of your label, use the '+' symbol next the font and set the font for the different size classes.

enter image description here

Upvotes: 1

Related Questions