Ios determines whether the screen is displayed as @ 2x or @ 3x to call the font size, @ 2x @ 3x
Traditional font size adaptation may be based on a ratio of the screen width to the iPhone 5 or iPhone 6 width. However, if you have such a requirement, a font is displayed on the mobile phone that displays the @ 2x image, and another fixed-size font is displayed on the mobile phone that displays the @ 3x image.
Therefore, the focus here is to distinguish between the mobile phone screen display image type @ 2x or @ 3x.
CGFloat scale = [UIScreen mainScreen]. scale. The scale attribute of UIScreen is 2 for iphone 5, 6 s, 7, 8, and 3 for iPhone plus and iphone X. So we have the following macro definition.
/* Font related */
# Define kScreenScale [UIScreen mainScreen]. scale // The iphone 3gs is 1; 4, 5, 5S, 6, 7, 8, etc. 2; plus X is 3
// @ 3x the screen size is 1.5 times that of @ 2x.
# Define kFontAuto (size) [UIFont systemFontOfSize :( size * kScreenScale/2.0)]