码迷,mamicode.com
首页 > 其他好文 > 详细

常用宏定义 - 系统相关

时间:2018-07-15 00:14:16      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:less   cse   get   tar   instance   常用宏   local   相关   hone   


/** 是否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)

常用宏定义 - 系统相关

标签:less   cse   get   tar   instance   常用宏   local   相关   hone   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!