// Frame
#define SCREEN_FRAME ([UIScreen mainScreen].applicationFrame)
// 寬度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
// 高度
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
// iPhone6寬比
#define KBaseW [UIScreen mainScreen].bounds.size.width / 375
// iPhone6高比
#define KBaseH [UIScreen mainScreen].bounds.size.height / 667
// RGBA
#define RGBA(R /*紅*/, G /*綠*/, B /*藍(lán)*/, A /*透明*/) [UIColor colorWithRed: (float)R / 255.f green: (float)G / 255.f blue: (float)B / 255.f alpha: A]
// RGB
#define RGB(r, g, b) [UIColor colorWithRed: (r) / 255.0 green: (g) / 255.0 blue: (b) / 255.0 alpha: 1.0]
// 沙盒目錄
#define kUserDefaults [NSUserDefaults standardUserDefaults]
// 獲取通知中心
#define kNotificationCenter [NSNotificationCenter defaultCenter]
// 設(shè)置隨機(jī)顏色
#define kRandomColor [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0 blue:arc4random_uniform(256) / 255.0 alpha:1.0]
// clear背景顏色
#define kClearColor [UIColor clearColor]
// 自定義高效率的 NSLog
#ifdef DEBUG
#define kLog(...) NSLog(@"%s 第%d行 \n %@\n\n", __func__, __LINE__, [NSString stringWithFormat:__VA_ARGS__])
#else
#define kLog(...)
#endif
// 弱引用/強(qiáng)引用
#define kWeakSelf(type) __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;
// 設(shè)置 view 圓角和邊框
#define kViewBorderRadius(View, Radius, Width, Color) \
\
[View.layer setCornerRadius: (Radius)]; \
[View.layer setMasksToBounds:YES]; \
[View.layer setBorderWidth:(Width)]; \
[View.layer setBorderColor:[Color CGColor]]
// 由角度轉(zhuǎn)換弧度 由弧度轉(zhuǎn)換角度
#define kDegreesToRadian(x) (M_PI * (x) / 180.0)
#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)
// 獲取keyWindow
#define kWindow [UIApplication sharedApplication].keyWindow
// 設(shè)置狀態(tài)條加載
#define kShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
// 收起狀態(tài)條加載
#define kHideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
// MBProgressHUD加載
#define kShowHUDAndActivity kBackView; [MBProgressHUD showHUDAddedTo:kWindow animated:YES]; kShowNetworkActivityIndicator()
// MBProgressHUD隱藏
#define kHiddenHUD [MBProgressHUD hideAllHUDsForView:kWindow animated:YES]; kHideNetworkActivityIndicator()
// 獲取圖片資源
#define kGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@", imageName]]
// 獲取當(dāng)前語(yǔ)言
#define kCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
// 使用 ARC 和 MRC
#if __has_feature(objc_arc)
// ARC
#else
// MRC
#endif
// 判斷是否為iPhone
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
// 判斷是否為iPad
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// 判斷是否為ipod
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
// 判斷是否為 iPhone 5/5s/SE
#define iPhone5SE [[UIScreen mainScreen] bounds].size.width == 320.0f && [[UIScreen mainScreen] bounds].size.height == 568.0f
// 判斷是否為iPhone 6/6s
#define iPhone6_6s [[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 667.0f
// 判斷是否為iPhone 6Plus/6sPlus
#define iPhone6Plus_6sPlus [[UIScreen mainScreen] bounds].size.width == 414.0f && [[UIScreen mainScreen] bounds].size.height == 736.0f
// 獲取系統(tǒng)版本
#define IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
// 判斷 iOS 8 或更高的系統(tǒng)版本
#define IOS_VERSION_8_OR_LATER (([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) ? (YES) : (NO))
// 判斷是真機(jī)還是模擬器
#if TARGET_OS_IPHONE
// iPhone Device
#endif
#if TARGET_IPHONE_SIMULATOR
// iPhone Simulator
#endif
// 沙盒目錄文件
// 獲取temp
#define kPathTemp NSTemporaryDirectory()
// 獲取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
// 獲取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
// GCD 的宏定義
// GCD - 一次性執(zhí)行
#define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
// GCD - 在Main線程上運(yùn)行
#define kDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
// GCD - 開(kāi)啟異步線程
#define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
沒(méi)有一蹴而就的天才酒来,只有不斷點(diǎn)亮天賦的勤者