美文网首页
iOS 常用宏收集

iOS 常用宏收集

作者: 大大东 | 来源:发表于2016-05-26 21:44 被阅读32次

    收集一些 宏 不断更新中。。。

    // App
    #define APP_VERSION                 [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
    
    // System Version
    #define SYSTEM_VERSION                             ([[[UIDevice currentDevice] systemVersion] floatValue])
    #define SYSTEM_VERSION_EQUAL_TO(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
    #define SYSTEM_VERSION_HIGHER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
    #define SYSTEM_VERSION_EQUAL_TO_OR_HIGHER_THAN(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
    #define SYSTEM_VERSION_LOWER_THAN(v)               ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
    #define SYSTEM_VERSION_EQUAL_TO_OR_LOWER_THAN(v)   ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
    
    
    // Color
    #define RGB(r,g,b)                  [UIColor colorWithRed:r / 255.f green:g / 255.f blue:b / 255.f alpha:1.f]
    #define RGBA(r,g,b,a)               [UIColor colorWithRed:r / 255.f green:g / 255.f blue:b / 255.f alpha:a]
    #define RGB_HEX(hex)                RGBA((float)((hex & 0xFF0000) >> 16),(float)((hex & 0xFF00) >> 8),(float)(hex & 0xFF),1.f)
    #define RGBA_HEX(hex,a)             RGBA((float)((hex & 0xFF0000) >> 16),(float)((hex & 0xFF00) >> 8),(float)(hex & 0xFF),a)
    
    
    
    // Language
    #define CURRENT_LANGUAGE            ([[NSLocale preferredLanguages] objectAtIndex:0])
    #define IS_LANGUAGE(l)              [CURRENT_LANGUAGE hasPrefix:l]
    #define IS_LANGUAGE_EN              IS_LANGUAGE(@"en")
    
    
    
    // Screen
    #define SCREEN_SIZE                 [[UIScreen mainScreen] bounds].size
    #define SCREEN_WIDTH                [[UIScreen mainScreen] bounds].size.width
    #define SCREEN_HEIGHT               [[UIScreen mainScreen] bounds].size.height

    相关文章

      网友评论

          本文标题:iOS 常用宏收集

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