iOS system to determine certain adaptation __iphone_os_version_max_allowed

Source: Internet
Author: User

Since the latest design font for the app is the square font after iOS9, the app has the lowest support ios7,so ... To uniformly fit the font in the constant profile class, as follows:

// fit font, IOS9 and above system using new font--square font #if __iphone_os_version_max_allowed >= __iphone_9_0#define kFontSize15 [Uifont fontwithname:@] Pingfangsc-light "size:15.0"#else#define kFontSize15 [Uifont systemfontofsize:15.0]#endif 

In the test environment of iOS8, print kFontSize15 is null, this shows that the above macro compiler condition to judge the condition is not correct, __iphone_os_version_max_allowed for the compiler, in different versions of the compiler Xcode, macro __ Iphone_os_version_max_allowed corresponds to a different version, xcode8.3 is like this:

#define __iphone_os_version_max_allowed     __iphone_10_3

So, #if后的判断条件不对, and this judgment applies to those third-party service developers who need to be compatible with the high-low Xcode version to ensure that the latest API runs on the lower version of Xcode without compiling errors. Same

#ifdef __IPHONE_9_0 is the same as above, only ensure that your code is not error-prone when compiling in a low version.

Finally, the adaptation is written in such a way:

#define System_version ([[Uidevice Currentdevice] systemversion])#define Ios9_or_later (system_version.floatvalue >= 9.0)#define kFontSize15 ios9_or_later? [Uifont fontwithname:@ "Pingfangsc-light" Size:15.0]:[uifont systemfontofsize:15.0]

iOS system to determine certain adaptation __iphone_os_version_max_allowed

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.