1.字号
#define kTY_7Font [UIFont systemFontOfSize:7*SCREEN_RATIO]
#define kTY_8Font [UIFont systemFontOfSize:8*SCREEN_RATIO]
#define kTY_9Font [UIFont systemFontOfSize:9*SCREEN_RATIO]
#define kTY_10Font [UIFont systemFontOfSize:10*SCREEN_RATIO]
#define kTY_11Font [UIFont systemFontOfSize:11*SCREEN_RATIO]
#define kTY_12Font [UIFont systemFontOfSize:12*SCREEN_RATIO]
2.系统版本号
#define kSystemVersion [[[UIDevice currentDevice] systemVersion] floatValue]
#define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
3.打印输出
#ifdef DEBUG
#define NSSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSSLog(...)
#endif
4.屏幕的宽高&宽度对比320的比例
//当前设备的屏幕宽度
#define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
//当前设备的屏幕高度
#define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
#define SCREEN_RATIO ([[UIScreen mainScreen] bounds].size.width)/320.0f
5.关于iPhone X的适配的一些宏定义
#define ISiPhoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom >0.0;\
}\
(isPhoneX);})
//状态栏高度
#define StatusBarHeight (CGFloat)(ISiPhoneX?(44):(20))
// 导航栏高度
#define kNavBarHBelow7 (44)
// 状态栏和导航栏总高度
#define NavBarHAbove7 (ISiPhoneX ? (88):(64))
// TabBar高度
#define TabBar_Height (ISiPhoneX ? (49+34) :49)
// 顶部安全区域远离高度
#define kTopBarSafeHeight (CGFloat)(ISiPhoneX?(44):(0))
// 底部安全区域远离高度
#define kBottomSafeHeight (CGFloat)(ISiPhoneX?(34):(0))
// iPhoneX的状态栏高度差值
#define kTopBarDifHeight (CGFloat)(ISiPhoneX?(24):(0))
#define STATE_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height