常用宏控整理

#define UIColorFromHexWithAlpha(hexValue,a) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:a]

#define UIColorFromHex(hexValue)            UIColorFromHexWithAlpha(hexValue,1.0)

#define UIColorFromRGBA(r,g,b,a)            [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define UIColorFromRGB(r,g,b)              UIColorFromRGBA(r,g,b,1.0)

#define IOS9_OR_LATER      ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0?YES:NO)

#define iOS8_OR_LATER      ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

#define IOS7_OR_LATER      ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0?YES:NO)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define Simulator          ([[UIDevice currentDevice].localizedModel isEqualToString:@"iPhone Simulator"])

#define kScreenWidth ([[UIScreen mainScreen]bounds].size.width)

#define kScreenHeight ([[UIScreen mainScreen]bounds].size.height)


#ifndef    weakify_self

#if __has_feature(objc_arc)

#define weakify_self autoreleasepool{} __weak __typeof__(self) weakSelf = self;

#else

#define weakify_self autoreleasepool{} __block __typeof__(self) blockSelf = self;

#endif

#endif

#ifndef    strongify_self

#if __has_feature(objc_arc)

#define strongify_self try{} @finally{} __typeof__(weakSelf) self = weakSelf;

#else

#define strongify_self try{} @finally{} __typeof__(blockSelf) self = blockSelf;

#endif

#endif

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • //----------------------图片相关---------------------------- ...
    码了个农啵阅读 887评论 0 4
  • 1 weakself和strongself #ifndef weakify #if DEBUG #ifhas_fe...
    涐罙擁那嗰懂涐阅读 718评论 1 1
  • iOS开发过程中,使用的一些常用宏定义 字符串是否为空#define kStringIsEmpty(str) ([...
    goyohol阅读 5,400评论 30 85
  • 又是一年清明祭。 清明时节雨纷纷,每年的清明节好像全世界都在下雨,以前在书上看到过一句话,到现在都记忆犹新。“清明...
    未静阅读 675评论 0 1
  • 早晨睡醒后来到客厅躺在沙发上,柔软的沙发仿佛能把我包裹进去,异常的舒服。此刻,出租房里只剩下了我一个人,其他的小伙...
    箱猫日和阅读 214评论 0 0