Nan Nan - 3 months ago 43
Objective-C Question

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.


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];