美文网首页
常用宏控整理

常用宏控整理

作者: lvzhehappy | 来源:发表于2017-04-10 13:55 被阅读5次

    #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

    相关文章

      网友评论

          本文标题:常用宏控整理

          本文链接:https://www.haomeiwen.com/subject/nausattx.html