iOS 系統版本的判斷


 iOS 宏定義系統版本的判斷

#define iOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
#define iOS10_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.1f)
 
很多人都是用的這種方法,在此之前我也用的這種宏定義的方法,但是在xcode的開發環境中已經定義好了很多 系統版本判別的宏定義 包含iOS 、 Mac、TVOS、WATCHOS的系統版本的宏,截圖如下:
  

 

 
只要在使用時 用下面的方法就可以了
 
#ifdef __IPHONE_7_0
  //iOS7的新特性代碼
#endif
 
或者是使用:
 
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
 
  //iOS7的新特性代碼
#endif(__IPHONE_OS_VERSION_MAX_ALLOWED 這個定義是在Simulator-IOS7.0/usr/include/AvailabilityInternal.h文件中)
 
就搞定了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM