iOS 常用的宏

/* -------- 屏幕宽高 -------- */

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)

#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)

/* -------- 打印日志 -------- */

#ifdef DEBUG

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

#else

#define NSLog(...)

#endif

/* -------- 系统版本 -------- */

#define IS_IOS7  ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 )

#define IS_IOS8  ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 )

#define IS_IOS9  ( [[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 )

/* -------- 颜色 -------- */

#define UICOLOR_RGB(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

#define UICOLOR_RANDOM  [UIColor colorWithRed:(arc4random()%255)/255.0 green:(arc4random()%255)/255.0 blue:(arc4random()%255)/255.0 alpha:1.0]

/* -------- 真机模拟器 -------- */

#if TARGET_OS_IPHONE

// iPhone Device

#endif

#if TARGET_IPHONE_SIMULATOR

// iPhone Simulator

#endif

原文地址:https://www.cnblogs.com/chenyanliang/p/9679182.html