iOS 常用的宏定義

//獲取屏幕的寬度、高度

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

//適配比例,以iphone6尺寸為基準(zhǔn)

#define wl ([UIScreen mainScreen].bounds.size.width/375)

#define hl ([UIScreen mainScreen].bounds.size.height/667)

//DEBUG模式下打印日志

#ifdef DEBUG

#define HLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

#else

#define HLog(...)

#endif

//獲取系統(tǒng)版本

#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

//判斷設(shè)備操作系統(tǒng)是否為iOS7

#define? IOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >=7.0)

//RGB顏色轉(zhuǎn)換 (16進(jìn)制->10進(jìn)制)

#define UIColorFromRGBA(rgbValue, alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 blue:((float)(rgbValue & 0x0000FF))/255.0 alpha:alphaValue]

//RGB顏色

#define RGBACOLOR(R,G,B,A) [UIColor colorWithRed:(R)/255.0 green:(G)/255.0 blue:(B)/255.0 alpha:(A)]

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0f]

//整體背景色

#define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]

//清除背景色

#define CLEARCOLOR [UIColor clearColor]

#define WHITECOLOR [UIColor whiteColor]

//整體字體顏色,大小

#define TEXT_COLOR [UIColor colorWithRed:(51)/255.0 green:(71)/255.0 blue:(113)/255.0 alpha:1.0]

#define TEXT_FONT? [UIFont systemFontOfSize:14*hl]

#define Text_Font? [UIFont systemFontOfSize:12*hl]

//方正黑體簡(jiǎn)體字體定義

#define FONT(F) [UIFont fontWithName:@"FZHTJW--GB1-0" size:F]

//定義一個(gè)API

#define APIURL @""

//GCD

#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)

#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

//NSUserDefaults 實(shí)例化

#define USER_DEFAULT [NSUserDefaults standardUserDefaults]

//由角度獲取弧度 有弧度獲取角度

#define angleToRadian(x) (M_PI*(x)/180.0)

#define radianToAngle(r) (r*180.0)/M_PI

//block塊呢,self->weakSelf

#define WeakSelf __weak typeof(self) weakSelf = self;

自己常用的一些宏定義,拿出來(lái)記錄一下,分享一下,萬(wàn)一有人需要呢??!

最后編輯于
?著作權(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)容

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