zoukankan      html  css  js  c++  java
  • iOS --- 总结Objective-C中经常使用的宏定义(持续更新中)

    将iOS开发中经常使用的宏定义整理例如以下,仅包括Objective-C。
    而对于Swift,不能使用宏,则能够定义全局函数或者extension。请參考博客iOS — 总结Swift中经常使用的全局函数和extension(持续更新中)

    //
    // Macro.h
    //
    // Objective-C useful macro for Chris Hu
    //
    
    
    // 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)
    
    #define COLOR_LIGHT_BLUE            RGB_HEX(0x7f8b97)
    #define COLOR_DEEP_BLUE             RGB_HEX(0x00b3d6)
    
    
    // Language
    #define CURRENT_LANGUAGE            ([[NSLocale preferredLanguages] objectAtIndex:0])
    #define IS_LANGUAGE(l)              [CURRENT_LANGUAGE hasPrefix:l]
    #define IS_LANGUAGE_EN              IS_LANGUAGE(@"en")
    
    
    // Font
    #define FONT_SOFIA_MEDIUM(s)        [UIFont fontWithName:@"SofiaProSoft-Medium" size:s]
    #define FONT_SOFIA_SOFT(s)          [UIFont fontWithName:@"SofiaProSoft" size:s]
    
    
    // Screen
    #define SCREEN_SIZE                 [[UIScreen mainScreen] bounds].size
    #define SCREEN_WIDTH                [[UIScreen mainScreen] bounds].size.width
    #define SCREEN_HEIGHT               [[UIScreen mainScreen] bounds].size.height
    
    
    // GCD
    #define GCD_GLOBAL(block)           dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
    #define GCD_MAIN(block)             dispatch_async(dispatch_get_main_queue(), block)
    
    
  • 相关阅读:
    uva 1362(区间dp+计数)
    uva 11174(排列组合+搜索)
    简单递推系列 uva习题
    基本计数方法系列 uva习题
    Codeforces Round #209 (Div. 2) Problem A Table(找规律)
    CodeChef November Challenge 2013 解题报告
    2012 chengdu现场赛 Browsing History HDU4464(简单字符串)
    CodeChef TechFest 2013 Cool Numbers(搜索)
    CodeChef Inscription 2013 Wonderland jewellery(简单题)
    页面滚动marquee标签
  • 原文地址:https://www.cnblogs.com/cxchanpin/p/7203069.html
Copyright © 2011-2022 走看看