iOS 那些你可能会用到的宏定义

释放双眼,带上耳机,听听看~!
#define SCREEN_WIDTH          [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT         [UIScreen mainScreen].bounds.size.height
#define SCREEN_SIZE           [UIScreen mainScreen].bounds.size
#define SCALE_WIDTH           SCREEN_WIDTH/375
#define STATUSBAR_HEIGHT      [[UIApplication sharedApplication] statusBarFrame].size.height
#define NAVIGATIONBAR_HEIGHT  self.navigationController.navigationBar.height
#define KISIPHONEX            ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define RGBColor(r,g,b)       [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RGBAColor(r,g,b,a)    [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
#define RandomColor           [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]

#define kFontSize(size)       [UIFont systemFontOfSize:size]

//弱 强引用
#define kWeakSelf(type)        __weak typeof(type) weak##type = type;
#define kStrongSelf(type)      __strong typeof(type) type = weak##type;

#define kGetImage(imageName)  [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

#define UUIDSTRING            [[UIDevice currentDevice].identifierForVendor UUIDString]
#define VERSION               [[UIDevice currentDevice].systemVersion floatValue]
#define kApplication          [UIApplication sharedApplication]
#define kKeyWindow            [UIApplication sharedApplication].keyWindow
#define kAppDelegate          [UIApplication sharedApplication].delegate
#define kUserDefaults         [NSUserDefaults standardUserDefaults]
#define kNotificationCenter   [NSNotificationCenter defaultCenter]
#define kAppVersion           [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//GCD  一次性执行
#define kDISPATCH_ONCE_BLOCK(onceBlock) static                         
dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock)
//GCD  Main线程上运行
#define kDISPATCH_MAIN_THREAD(mainQueueBlock)                            
dispatch_async(dispatch_get_main_queue(), mainQueueBlock)
//GCD 开启异步线程
#define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock)  
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl)

人已赞赏
iOS文章

iOS 使用segue时如何实现login的判断

2019-10-11 5:50:53

iOS文章

iOS 播放 gif 动画

2019-10-11 8:22:23

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索