///屏幕的寬度
#define kScreenWidth [UIScreen mainScreen].bounds.size.width
///屏幕的高度
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
///storyboard
#define STO [UIStoryboard storyboardWithName:"Main" bundle:nil]
//定義字體函數(shù)
#define FONT(a) [UIFont systemFontOfSize:a ]
//系統(tǒng)標(biāo)準(zhǔn)保存鍵值
#define UserDefaultStandard [NSUserDefaults standardUserDefaults]
/** 弱引用*/
#define kWeakSelf(type) __weak typeof(type) weak##type = type;
/** 強引用*/
#define kStrongSelf(type) __strong typeof(type) type = weak##type;
/** 由角度轉(zhuǎn)換弧度*/
#define kDegreesToRadian(x) (M_PI * (x) / 180.0)
/** 由弧度轉(zhuǎn)換角度*/
#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)
/** 獲取沙盒 Document 路徑*/
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
/** 獲取沙盒 temp 路徑(注:iPhone 重啟會清空)*/
#define kTempPath NSTemporaryDirectory()
/** 獲取沙盒 Cache 路徑*/
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
///重寫log
#ifdef DEBUG
#define DLog(...) NSLog(__VA_ARGS__)
#else
#define DLog(...)
#endif
//定義顏色函數(shù)
#define RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
#define RGBCOLOR(a,b,c) RGBA(a,b,c,1.0)
#define UIColorFromRGB(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]
// 控件尺寸適配的宏函數(shù)
#define kFit(x) (kScreenWidth*((x)/375))
//G-C-D
#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)
// 不堵塞線程并在主線程的延遲執(zhí)行 timer:延遲時間,單位:秒;與主線程同步
#define GCDMainDelay(timer,block) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, INT64_C(timer) * NSEC_PER_SEC), dispatch_get_main_queue(), block)
// 將code調(diào)到主線程執(zhí)行核无,與主線程同步
#define GCDMain(block) dispatch_async(dispatch_get_main_queue(), block)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者