如果工程很大,头文件很多,而有几个头文件又是经常要用的,那么
把这些头文件全部写到预编译头文件里面去就不用多次引用了
1.右键组名,New File-》IOS-》other选择PCH文件
2.在Build Settings里面找到Prefix Header
3.添加PCH文件,$(SRCROOT)/项目名/***.pch
还有几个常用的宏分享下
1.#define IPHONE4 [UIScreen mainScreen].bounds.size.height < 500
//屏幕宽高
2.#define kWidth [UIScreen mainScreen].bounds.size.width
3.#define kHeight [UIScreen mainScreen].bounds.size.height
//设置颜色
4.#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
5.#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
6.#define HEXCOLOR(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]
7.#define HEXACOLOR(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)]