iOS开发之判断机型,系统版本
2016-10-13 本文已影响6565人
小璐有大大的梦想
OS 判断机型
开发中可能对不同的机型做出相应的适配
是否为iPhone6,6s,7
#ifndef iPhone6
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \\\\
CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#endif
是否为iPhone6P,7P
#ifndef iPhone6P
#define iPhone6P ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \\\\
CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#endif
```
是否为iPhone5系列机型
ifndef iPhone5
define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \\
CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
endif
是否为iPhone4系列机型
ifndef iPhone4
define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? \\
CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
endif
判断iOS系统版本
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)