iOS开发

iOS开发常用宏定义

2019-11-22  本文已影响0人  风规自远

// 打印日志

#ifdef DEBUG

// debug模式打印

#define OMGLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);

#else

// 打包上前要进行注释

//#define OMGLog(FORMAT, ...) fprintf(stderr, "%s:%d\t%s\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String])

#define OMGLog(...)//打包上线解开注释

#endif 

#pragma mark - 设备型号识别

#define is_IOS_10 ([[[UIDevice currentDevice] systemVersion] floatValue] >=10.0)

/**

 * 颜色快速取值器

 */

#define RGBACOLOR(R,G,B,A) [UIColor colorWithRed:(R)/255.0fgreen:(G)/255.0fblue:(B)/255.0falpha:(A)]

/**

 * 十六进制色值

 */

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue &0xFF0000) >>16))/255.0green:((float)((rgbValue &0xFF00) >>8))/255.0blue:((float)(rgbValue &0xFF))/255.0alpha:1.0]

/**

 *  获取屏幕的高度

 */

#define kScreenHeight [UIScreen mainScreen].bounds.size.height

/**

 *  获取屏幕的宽度

 */

#define kScreenWidth [UIScreen mainScreen].bounds.size.width

/**

 * 判断是否为iPad

 */

#define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

上一篇下一篇

猜你喜欢

热点阅读