iOS常用的宏定義 pch文件

如果有幫助到你就給個贊吧 謝謝咯...

  1. pch 文件路徑 build settings 搜索Prifixheader
    $(SRCROOT)/黃色的文件夾名/黃色文件夾名/一層一層直到PCH文件名.pch
    !??! 文件層要統一 工程里的文件夾包含關系要和Finder 里的一致

  2. 常用宏定義
    顏色

#define kRGBColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]

設施控件圓角

#define kViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]

設施圓角 邊框線寬度 顏色

#define kViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

歸檔

#define kUserDefaults [NSUserDefaults standardUserDefaults]

屏幕長寬

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height

通知

#define kNoteCenter [NSNotificationCenter defaultCenter]

// 弱引用

#define kWeakSelf __weak typeof(self) weakSelf = self

/*Dubug相關/


#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define NSLog(...)
#define debugMethod()
#endif
#ifdef DEBUG
#define WSLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
//分別是方法地址,文件名,在文件的第幾行,自定義輸出內容
#else
#define **Log( s, ... )
#endif
//不同屏幕尺寸字體適配
#define kScreenWidthRatio  (UIScreen.mainScreen.bounds.size.width / 375.0)
#define kScreenHeightRatio (UIScreen.mainScreen.bounds.size.height / 667.0)
#define AdaptedWidth(x)  ceilf((x) * kScreenWidthRatio)
#define AdaptedHeight(x) ceilf((x) * kScreenHeightRatio)
#define AdaptedFontSize(R)     [UIFont systemFontOfSize:AdaptedWidth(R)]

干貨代碼 我的一個純代碼的基礎框架有各種常用的分類封裝入手即用

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容