iOS Pure Code suitability judgment

Source: Internet
Author: User

To provide you with a set of code matching the judgment, you can use directly, create a new. h file, and then paste the code in, you can directly use


The code to write in. h:

#define IS_IPAD (ui_user_interface_idiom () = Uiuserinterfaceidiompad)

#define Is_iphone (ui_user_interface_idiom () = Uiuserinterfaceidiomphone)

#define IS_IPHONE_5 (Is_iphone && [UIScreen mainscreen] bounds].size.height = 568.0)

#define IS_IPHONE_6 (Is_iphone && [UIScreen mainscreen] bounds].size.height = 667.0)

#define Is_iphone_6plus (Is_iphone && [UIScreen mainscreen] nativescale] = = 3.0f)

#define Is_iphone_6_plus (Is_iphone && [UIScreen mainscreen] bounds].size.height = 736.0)


#define Is_iphone_6_plus ([UIScreen instancesrespondtoselector: @selector (currentmode)]? (Cgsizeequaltosize (Cgsizemake (1125, 2001), [[UIScreen mainscreen] currentmode].size) | | Cgsizeequaltosize (Cgsizemake (1242, 2208), [[UIScreen Mainscreen] currentmode].size)): NO)


iphone 6 Plus Standard mode

#define IS_IPHONE_6_PLUS_NORMAL ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (1242, 2208), [[UIScreen Mainscreen] currentmode].size): NO)


#define IS_IPHONE_6_PLUS_BIG ([UIScreen instancesrespondtoselector: @selector (currentmode)]? Cgsizeequaltosize (Cgsizemake (1125, 2001), [[UIScreen Mainscreen] currentmode].size): NO)



In your view controller, you need to match the inverse of the judgment:

if (is_iphone_6_plus) {

{


}

else if (is_iphone_6)

{

}

else if (Is_iphone_5 | | Is_iphone)

{


}

}



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.