iOS常用的宏定義 pch文件

如果有幫助到你就給個(gè)贊吧 謝謝咯...

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

  2. 常用宏定義
    顏色

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

設(shè)施控件圓角

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

設(shè)施圓角 邊框線寬度 顏色

#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]

屏幕長(zhǎng)寬

#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相關(guān)/


#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__] )
//分別是方法地址,文件名,在文件的第幾行,自定義輸出內(nèi)容
#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)]

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Demo_github pch文件創(chuàng)建 在工程中新建一個(gè)PCH 文件:New File ->Other ->PCH...
    SkyMing一C閱讀 4,253評(píng)論 5 3
  • 定義了一些常用的宏,寫(xiě)代碼的時(shí)候用起來(lái)挺方便的,添加了pch文件,設(shè)置了相對(duì)路徑;設(shè)置pch文件相對(duì)路徑的方法:設(shè)...
    SnailLi閱讀 1,804評(píng)論 0 1
  • /**獲取屏幕寬度與高度 導(dǎo)航,tabbar高度*/ #define SCREEN_WIDTH [UIScree...
    MUYO_echo閱讀 776評(píng)論 0 3
  • 在工作中, 很多小伙伴都會(huì)在PCH文件定義一些常用的宏,但是又怕寫(xiě)這些簡(jiǎn)單的宏浪費(fèi)時(shí)間,又有時(shí)候忘記怎么定義了怎么...
    迪亞波羅閱讀 542評(píng)論 0 0
  • 來(lái)源于CocoaChina 在工作中, 很多小伙伴都會(huì)在PCH文件定義一些常用的宏,但是又怕寫(xiě)這些簡(jiǎn)單的宏浪費(fèi)時(shí)間...
    iOS學(xué)末閱讀 850評(píng)論 3 7

友情鏈接更多精彩內(nèi)容