常用宏定义 - 系统相关
Posted ch520
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了常用宏定义 - 系统相关相关的知识,希望对你有一定的参考价值。
/** 是否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)
以上是关于常用宏定义 - 系统相关的主要内容,如果未能解决你的问题,请参考以下文章