//设备型号
#define IS_IPAD [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
#define IS_IPHONE [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )480) < DBL_EPSILON )
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )568) < DBL_EPSILON )
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )667) < DBL_EPSILON )
#define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double )960) < DBL_EPSILON )
//系统版本
#define IS_IOS_VERSION floorf([[UIDevice currentDevice].systemVersion floatValue]
#define IS_IOS_5 floorf([[UIDevice currentDevice].systemVersion floatValue]) ==5.0 ? 1 : 0
#define IS_IOS_6 floorf([[UIDevice currentDevice].systemVersion floatValue]) ==6.0 ? 1 : 0
#define IS_IOS_7 floorf([[UIDevice currentDevice].systemVersion floatValue]) ==7.0 ? 1 : 0
#define IS_IOS_8 floorf([[UIDevice currentDevice].systemVersion floatValue]) ==8.0 ? 1 : 0
#define IS_IOS_9 floorf([[UIDevice currentDevice].systemVersion floatValue]) ==9.0 ? 1 : 0
//物理屏幕尺寸
#define IH_DEVICE_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define IH_DEVICE_WIDTH [[UIScreen mainScreen] bounds].size.width
//自定义的NSLog
方法一:简单粗暴
#ifdef DEBUG //调试
#define XBYLog(...) NSLog(__VA_ARGS__)
#else //发布
#define XBYLog(...)
#endif
方法二:高端一些
#ifdef DEBUG
#define XLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define XLog(FORMAT, ...) nil;
#endif
方法三:
#ifdef DEBUG
#define XBYLog(format, ...) NSLog((@"%s " "%s " "%d行 " format), [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define XBYLog(FORMAT, ...) nil;
#endif
//基于自定义Log的打印函数名
#define XBYFunc XBYLog(@"%s",__func__)
#endif
iOS实战之常用宏定义
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...