在开发一个iOS项目的时候进行Pch文件的配置是必不可少的,它可以将多个类里面共用的固定的代码段以”宏”的形式在每一个类里面进行编译,譬如”获取屏幕高度宽度”,整个项目使用的”通用颜色”,结合”类扩展”使用可以大大的降低代码的冗杂度….下面放一些Pch里面必用的.
#ifdef __OBJC__
#import "UIView+ZZFExtension.h"
#import "UIBarButtonItem+ZZFExtension.h"
#import "UITextField+ZZFExtension.h"
#import "UIImage+ZZFExtension.h"
#import "ZZFConst.h"
#import "UIImageView+ZZFExtension.h"
#define ZZF_WIDTH [UIScreen mainScreen].bounds.size.width
#define ZZF_HEIGHT [UIScreen mainScreen].bounds.size.height
/*** 日志 ***/
#ifdef DEBUG
#define ZZFLog(...) NSLog(__VA_ARGS__)
#else
#define ZZFLog(...)
#endif
#define ZZFLogFunc ZZFLog(@"%s", __func__);
/*** 颜色 ***/
#define ZZFColorA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)/255.0]
#define ZZFColor(r, g, b) ZZFColorA((r), (g), (b), 255)
#define ZZFRandomColor ZZFColor(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))
#define ZZFrayColor(v) ZZFColor((v), (v), (v))
#define ZZFCommonBgColor ZZFrayColor(206)
#endif
在工程Project里要配置,prefix header—以及它上面的预编译YES.
$(SRCROOT)/…/…
配置参考链接:http://www.jianshu.com/p/67ce72c4ad6c