1.屏幕宽高
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
2.手机型号
#define kISiPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define kScreenMaxLength (MAX(kScreenWidth, kScreenHeight))
#define kScreenMinLength (MIN(kScreenWidth, kScreenHeight))
#define kISiPhone5 (kISiPhone && kScreenMaxLength == 568.0)
#define kISiPhone6 (kISiPhone && kScreenMaxLength == 667.0)
#define kISiPhone6P (kISiPhone && kScreenMaxLength == 736.0)
#define kISiPhoneX (kISiPhone && kScreenMaxLength == 812.0)
#define kISiPhoneXr (kISiPhone && kScreenMaxLength == 896.0)
#define kISiPhoneXX (kISiPhone && kScreenMaxLength > 811.0)
#define IOS8 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0)
3.适配相关
#define kScale_W(w) ((kScreenWidth)/375) * (w)//6为标准适配的,如果需要其他标准可以修改
#define kScale_H(h) (kScreenHeight/667) * (h)
#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height//状态栏高度
#define kStatusBarHeight (kISiPhoneX?44:20)//状态栏高度
#define kTabBarHeight (StatusBarHeight > 20 ? 83 : 49)//标签栏高度
#define kNavBarHeight (StatusBarHeight + 44)//导航栏高度
#define kSafeAreaBottom (kISiPhoneX ? 34 : 0)//安全区高度
4.字体样式
#define kBoldFont(x) [UIFont boldSystemFontOfSize:x]
#define kFont(x) [UIFont systemFontOfSize:x]
#define kNameFont(x) [UIFont fontWithName:@"Heiti SC"size:x]
5.颜色设置
#define kRGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]//RGB格式
#define kRGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]//RGBA格式
#define kRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]//随机颜色
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue &0xFF0000) >>16))/255.0green:((float)((rgbValue &0xFF00) >>8))/255.0blue:((float)(rgbValue &0xFF))/255.0alpha:1.0]//16进制颜色
6.系统对象
#define kApplication [UIApplication sharedApplication]//APP对象 (单例对象)
#define kKeyWindow [UIApplication sharedApplication].keyWindow//主窗口 (keyWindow)
#define kUserDefaults [NSUserDefaults standardUserDefaults]//NSUserDefaults实例化
#define kNotificationCenter [NSNotificationCenter defaultCenter]//通知中心 (单例对象)
#define KPostNotification(name,obj,info) [[NSNotificationCenter defaultCenter]postNotificationName:name object:obj userInfo:info]//发送通知
#define kVersion [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]//APP版本号
#define kSystemVersion [[UIDevice currentDevice] systemVersion]//系统版本号
7.简单调用
#define kGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]//加载图片
#define kWeakSelf(type) __weak typeof(type) weak##type = type//弱引用
#define kStrongSelf(type) __strong typeof(type) type = weak##type//强引用
#define kLoadNib(nibName) [UINib nibWithNibName:nibName bundle:[NSBundle mainBundle]]//加载xib
#define kStringFormat(format,...) [NSString stringWithFormat:format,##__VA_ARGS__]//字符串拼接
//属性快速声明(建议使用代码块)
#define kPropertyString(name) @property(nonatomic,copy)NSString *name
#define kPropertyStrong(type,name) @property(nonatomic,strong)type *name
#define kPropertyAssign(name) @property(nonatomic,assign)NSInteger name
8. 获取时间
#define kCurrentYear [[NSCalendar currentCalendar] component:NSCalendarUnitYear fromDate:[NSDate date]]//获得当前的年份
#define kCurrentMonth [[NSCalendar currentCalendar] component:NSCalendarUnitMonth fromDate:[NSDate date]]//获得当前的月份
#define kCurrentDay [[NSCalendar currentCalendar] component:NSCalendarUnitDay fromDate:[NSDate date]]//获得当前的日期
#define kCurrentHour [[NSCalendar currentCalendar] component:NSCalendarUnitHour fromDate:[NSDate date]]//获得当前的小时
#define kCurrentMin [[NSCalendar currentCalendar] component:NSCalendarUnitMinute fromDate:[NSDate date]]//获得当前的分
#define kCurrentSec [[NSCalendar currentCalendar] component:NSCalendarUnitSecond fromDate:[NSDate date]]//获得当前的秒