iOS常用宏定义

NSLog

#ifdef DEBUG
#   define DLog(...) NSLog(__VA_ARGS__)
#else
#   define DLog(...)
#endif

Dealloc

#define DEALLOC -(void)dealloc{NSLog(@"%@ dealloc", NSStringFromClass([self class]));}

Size

#define kSCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define kSCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define kSTATUS_BAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height

#define FIX_SIZE(num) ((num) * kSCREEN_WIDTH /320)
#define FIX_FONT_SIZE(size) kSCREEN_WIDTH <375? ((size +4.0) /2.0) : kSCREEN_WIDTH ==375? ((size +8.0) /2.0) : ((size +12.0) /2.0)
#define Font(size) [UIFont systemFontOfSize:FIX_FONT_SIZE(size)]

#define kNAVI_BAR_HEIGHT 44.0
#define kSTATUS_NAVI_BAR_HEIGHT 64.0

Color

#define RGBA(r, g, b, a) [UIColor colorWithRed:(r) / 255.0 green:(g) / 255.0 blue:(b) / 255.0 alpha:(a)]
#define RGB(r, g, b) RGBA(r, g, b, 255)

#define HEX_RGBA(rgba) RGBA(((rgba) & 0xff000000) >> 24, \
((rgba) & 0x00ff0000) >> 16, \
((rgba) & 0x0000ff00) >> 8, \
((rgba) & 0x000000ff) >> 0)

#define HEX_RGB(rgb) HEX_RGBA(((rgb) << 8) + 0xff)

你可能感兴趣的:(iOS常用宏定义)