iOS determines whether the screen displays @2x or @3x to call the font size

Source: Internet
Author: User

The traditional font size adaptation may fit according to the width of the screen with a ratio of iphone5 or iphone6 width. But if there is a need to display a font on the phone that displays the @2x picture, another fixed-size font appears on the phone that displays the @3x picture.

So the point here is to distinguish between the screen display of the mobile phone is the @2x type or the @3x type.

CGFloat scale = [UIScreen Mainscreen].scale, it's up. The UIScreen's Scale property is 2 on IPhone 5,6,6s,7,8 and 3 for plus,iphone x printing. So there's the following macro definition

/* FONT-related */

#define Kscreenscale [UIScreen mainscreen].scale//iphone 3GS for 1;4,5,5s,6,7,8 etc for 2;plus x for 3

@3x screen font is 1.5 times times larger than the @2x font

#define KFONTAUTO (size) [Uifont systemfontofsize: (Size * kscreenscale/2.0)]

iOS determines whether the screen displays @2x or @3x to call the font size

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.