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