iOS中PCH文件的配置
- 新建.pch文件
- 在Bulid Setting中搜索prefix
- 预编译Precompile Prefix Header设置为Yes
- Prefix Header路径设置为:$(PRODUCT_NAME)/XXX.pch
PCH文件常用宏
#ifdef DEBUG // 调试
#define NSLog(...) NSLog(@"%s %d行 %@", __func__, __LINE__, [NSString stringWithFormat:__VA_ARGS__])
#else // 发布
#define NSLog(...)
#endif
//屏幕尺寸
#define ScreenW [UIScreen mainScreen].bounds.size.width
#define ScreenH [UIScreen mainScreen].bounds.size.height
#define ScaleWidth (LLScreenW / 375.f)
#define ScaleHeight (LLScreenH / 667)
//系统
#define iPhone6P ([UIScreen mainScreen].bounds.size.height == 736)
#define iPhone6 ([UIScreen mainScreen].bounds.size.height == 667)
#define iPhone5 ([UIScreen mainScreen].bounds.size.height == 568)
#define iPhone4 ([UIScreen mainScreen].bounds.size.height == 480)
#define iOS8 ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)
#define HUDBackgroundColor UIColorWithRGBA(41, 51, 63, 0.6) //0.6
#define UIColorWithRGBA(r, g, b, a) [[UIColor alloc] initWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define UIColorWithRGB(r, g, b) UIColorWithRGBA(r, g, b, 1.0)
#define UIColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define UIColorFromRGBA(rgbValue,alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:alphaValue]
#define tableViewBackgroundColor UIColorFromRGB(0xf7f7f7) //tableview背景灰色
#define WeakSelf(weakSelf) __weak __typeof(&*self)weakSelf = self;