将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)

iOS --- 总结Objective-C中经常使用的宏定义(持续更新中)的更多相关文章

  1. 常用的iOS 宏定义 (持续更新中)

    1.System Versioning Preprocessor Macros #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevic ...

  2. iOS中容易混淆的知识点(持续更新中)

    1.成员变量和属性的区别 @interface Person : NSObject { NSString *_sex; } @property (nonatomic, copy) NSString * ...

  3. IOS比较常用的第三方组件及应用源代码(持续更新中)

    把平时看到或项目用到的一些插件进行整理,文章后面分享一些不错的实例,若你有其它的插件欢迎分享,不断的进行更新~ 一:第三方插件 1:基于响应式编程思想的oc 地址:https://github.com ...

  4. dubbo初认知(dubbo和springCloud关系,在微服务架构中的作用等)(持续更新中)

    一:dubbo是什么? dobbuo是阿里开源的一个高性能优秀的服务框架, 可通过高性能的 RPC 实现服务的输出和输入功能,使得应用可以和 高性能的rpc实现输入和输出的功能,可以了  Spring ...

  5. H5移动端IOS/Android兼容性总结,持续更新中…

    H5移动端IOS/Android兼容性总结,持续更新中… 1. IOS不识别日期 new Date("2018-07-01 08:00:00")在Android下正常显示可以直接进 ...

  6. 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )

    本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...

  7. git常用命令(持续更新中)

    git常用命令(持续更新中) 本地仓库操作git int                                 初始化本地仓库git add .                       ...

  8. Atom使用记录(持续更新中)

    部分内容取自:http://www.jianshu.com/p/dd97cbb3c22d,我自己也在使用,持续更新中 Atom安装插件在窗口中File---Setting---install 在里面进 ...

  9. Pig基础学习【持续更新中】

    *本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.* Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的,可以作为MapR ...

随机推荐

  1. js常见面试题

    1.大小写转化,将字符串转化成驼峰的方法 例:border-bottom-color转化为:borderBottomColor var str="border-bottom-color&qu ...

  2. read content in a text file in python

    ** read text file in pythoncapability: reading =text= from a text file 1. open the IDLE text editor  ...

  3. sort_main_extable

    参考:Linux异常表 1.函数调用关系 asmlinkage void __init start_kernel(void) -->sort_main_extable(); -->sort ...

  4. WIN10配置JDK

    系统变量→新建 JAVA_HOME 变量 变量值填写jdk的安装目录(本人是 E:\Java\jdk1.7.0) 系统变量→寻找 Path 变量→编辑 在变量值最后输入 %JAVA_HOME%\bin ...

  5. Python中正则表达式讲解

    正则表达式是匹配字符串的强大武器,它的核心思想是给字符串定义规则,凡是符合规则的字符串就是匹配了,否则就是不合法的.在介绍Python的用法之前,我们先讲解一下正则表达式的规则,然后再介绍在Pytho ...

  6. Hive 启动报错,需先启动元数据

    Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable ...

  7. 00051_static关键字

    1.static概念 当在定义类的时候,类中都会有相应的属性和方法.而属性和方法都是通过创建本类对象调用的.当在调用对象的某个方法时,这个方法没有访问到对象的特有数据时,方法创建这个对象有些多余.可是 ...

  8. chromedriver 下载

    https://sites.google.com/a/chromium.org/chromedriver/downloads   百度网盘链接:https://pan.baidu.com/s/1nwL ...

  9. 彻底解决python cgi 编程出现的编码问题

    Answering this for late-comers because I don't think that the posted answers get to the root of the ...

  10. 学习笔记6——插件 API,“过滤器”(Filters)和“动作”(Actions)

    WordPress 中有一种叫执行挂勾的机制,允许插件把一些功能“挂载”到 WordPress 当中.也就是说,在系统运行至某一个环节时,去调用插件内的一些函数.执行挂勾分为两种: 动作 (Actio ...