#import #ifndef __IPHONE_5_0 #warning "This project uses features only available in iOS SDK 5.0 and later." #endif #ifdef __OBJC__ @import UIKit; @import Foundation; @import Masonry; #import "CMWarnHUD.h" #import #import #endif #define WeakSelf __weak __typeof(&*self)weakSelf = self; #define W [UIScreen mainScreen].bounds.size.width/375.0 #define screenWidth [UIScreen mainScreen].bounds.size.width #define screenHeight [UIScreen mainScreen].bounds.size.height #define rgba(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)] #define safeBarHeight [UIApplication sharedApplication].windows.firstObject.safeAreaInsets.top #define safeBottomHeight [UIApplication sharedApplication].windows.firstObject.safeAreaInsets.bottom #define UIFONT(key) [UIFont systemFontOfSize:(key)] #define UIBOLDFONT(key) [UIFont boldSystemFontOfSize:(key)] #define SafeBlock(BlockName, ...) ({ !BlockName ? nil : BlockName(__VA_ARGS__); }) #ifndef __OPTIMIZE__ #define NSLog(format,...) fprintf(stderr, "时间:%s %s\n", __TIME__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String]) #else #define NSLog(...) NSLog(@"") #endif #define kWeakSelf(type) __weak typeof(type) weak##type = type; #define kStrongSelf(type) __strong typeof(type) type = weak##type; #define kSafeBottomMargin \ ({CGFloat safeBottomMargin = 0; \ if (@available(iOS 11.0, *)) { \ UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window]; \ safeBottomMargin = keyWindow.safeAreaInsets.bottom; \ } \ (safeBottomMargin); \ }) #define kSafeTopMargin \ ({CGFloat safeTopMargin = 0; \ if (@available(iOS 11.0, *)) { \ UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window]; \ safeTopMargin = keyWindow.safeAreaInsets.top; \ } \ (safeTopMargin); \ }) #define kSafeRightMargin \ ({CGFloat safeBottomMargin = 0; \ if (@available(iOS 11.0, *)) { \ UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window]; \ safeBottomMargin = keyWindow.safeAreaInsets.right; \ } \ (safeBottomMargin); \ }) #define kSafeLeftMargin \ ({CGFloat safeBottomMargin = 0; \ if (@available(iOS 11.0, *)) { \ UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window]; \ safeBottomMargin = keyWindow.safeAreaInsets.left; \ } \ (safeBottomMargin); \ })