首页 > 其他 > 详细

常用宏定义 - 系统相关

时间:2018-07-15 00:05:11      阅读:253      评论:0      收藏:0      [点我收藏+]

/** 是否iPad */
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

/** 是否iPad */
#define someThing (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)? ipad: iphone

/** 获取系统版本 */
#define IOS_VERSION [[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [UIDevice currentDevice] systemVersion]

/** 获取当前语言 */
#define CurrentLanguage ([NSLocale preferredLanguages] objectAtIndex:0])

/** 判断是否 Retina屏、设备是否%fhone 5、是否是iPad */
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

/** 判断设备的操做系统是不是ios7 */
#define IOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0]

/** 判断当前设备是不是iphone5 */
#define kScreenIphone5 (([UIScreen mainScreen] bounds].size.height)>=568)

/** 获取当前屏幕的高度 */
#define CHScreenH ([UIScreen mainScreen].applicationFrame.size.height)
/** 获取当前屏幕的宽度 */
#define CHScreenW ([UIScreen mainScreen].applicationFrame.size.width)

/** 定义一个define函数 */
#define TT_RELEASE_CF_SAFELY(__REF) { if (nil != (__REF)) { CFRelease(__REF); __REF = nil; } }

/** 判断是真机还是模拟器 */
#if TARGET_OS_IPHONE
    //iPhone Device
#endif

#if TARGET_IPHONE_SIMULATOR
    //iPhone Simulator
#endif

/** 检查系统版本 */
#define SYSTEM_VERSION_EQUAL_TO(v) ([[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

常用宏定义 - 系统相关

原文:https://www.cnblogs.com/CH520/p/9311248.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!