pch 文件路径 build settings 搜索Prifixheader
$(SRCROOT)/黄色的文件夹名/黄色文件夹名/一层一层直到PCH文件名.pch
!!! 文件层要统一 工程里的文件夹包含关系要和Finder 里的一致
常用宏定义
颜色
#define kRGBColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
设施控件圆角
#definekViewRadius(View,Radius)\\[View.layer setCornerRadius:(Radius)];\[View.layer setMasksToBounds:YES]
设施圆角 边框线宽度 颜色
#definekViewBorderRadius(View,Radius,Width,Color)\\[View.layer setCornerRadius:(Radius)];\[View.layer setMasksToBounds:YES];\[View.layer setBorderWidth:(Width)];\[View.layer setBorderColor:[Color CGColor]]
归档
#definekUserDefaults [NSUserDefaults standardUserDefaults]
屏幕长宽
#definekScreenWidth[UIScreen mainScreen].bounds.size.width#definekScreenHeight[UIScreen mainScreen].bounds.size.height
通知
#definekNoteCenter [NSNotificationCenter defaultCenter]
// 弱引用
#definekWeakSelf __weak typeof(self) weakSelf = self
/*Dubug相关/
#ifdefDEBUG#defineNSLog(...) NSLog(__VA_ARGS__)#definedebugMethod() NSLog(@"%s", __func__)#else#defineNSLog(...)#definedebugMethod()#endif#ifdefDEBUG#defineWSLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )//分别是方法地址,文件名,在文件的第几行,自定义输出内容#else#define**Log( s, ... )#endif
//不同屏幕尺寸字体适配#definekScreenWidthRatio (UIScreen.mainScreen.bounds.size.width / 375.0)#definekScreenHeightRatio (UIScreen.mainScreen.bounds.size.height / 667.0)#defineAdaptedWidth(x) ceilf((x) * kScreenWidthRatio)#defineAdaptedHeight(x) ceilf((x) * kScreenHeightRatio)#defineAdaptedFontSize(R) [UIFont systemFontOfSize:AdaptedWidth(R)]
网友评论