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)
iOS --- 总结Objective-C中经常使用的宏定义(持续更新中)的更多相关文章
- 常用的iOS 宏定义 (持续更新中)
1.System Versioning Preprocessor Macros #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevic ...
- iOS中容易混淆的知识点(持续更新中)
1.成员变量和属性的区别 @interface Person : NSObject { NSString *_sex; } @property (nonatomic, copy) NSString * ...
- IOS比较常用的第三方组件及应用源代码(持续更新中)
把平时看到或项目用到的一些插件进行整理,文章后面分享一些不错的实例,若你有其它的插件欢迎分享,不断的进行更新~ 一:第三方插件 1:基于响应式编程思想的oc 地址:https://github.com ...
- dubbo初认知(dubbo和springCloud关系,在微服务架构中的作用等)(持续更新中)
一:dubbo是什么? dobbuo是阿里开源的一个高性能优秀的服务框架, 可通过高性能的 RPC 实现服务的输出和输入功能,使得应用可以和 高性能的rpc实现输入和输出的功能,可以了 Spring ...
- H5移动端IOS/Android兼容性总结,持续更新中…
H5移动端IOS/Android兼容性总结,持续更新中… 1. IOS不识别日期 new Date("2018-07-01 08:00:00")在Android下正常显示可以直接进 ...
- 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )
本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...
- git常用命令(持续更新中)
git常用命令(持续更新中) 本地仓库操作git int 初始化本地仓库git add . ...
- Atom使用记录(持续更新中)
部分内容取自:http://www.jianshu.com/p/dd97cbb3c22d,我自己也在使用,持续更新中 Atom安装插件在窗口中File---Setting---install 在里面进 ...
- Pig基础学习【持续更新中】
*本文参考了Pig官方文档以及已有的一些博客,并加上了自己的一些知识性的理解.目前正在持续更新中.* Pig作为一种处理大规模数据的高级查询语言,底层是转换成MapReduce实现的,可以作为MapR ...
随机推荐
- 【php】 给数组重建索引
array_values $a = [1,2]; unset($a[1]); $a[] = 3; print_r($a); // 输出 [0=>1,2=>3]
- Spring,Mybatis,Springmvc框架整合项目(第一部分)
一.说在前面的话 本篇博文实现一个注册登录小项目,使用spring,mybatis,springmvc框架进行整合,我们创建的是一个maven工程,主要是方便jar包版本的管理.项目使用eclispe ...
- PAT Basic 1055
1055 集体照 拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下: 每排人数为 N/K(向下取整),多出来的人全部站在最后一排: 后排所有人的个子都不比前排任何人矮: 每排 ...
- Repo command reference
Repo command reference In this document init sync upload diff download forall prune start status Rep ...
- Developing
To work with the Android code, you will need to use both Git and Repo. In most situations, you can u ...
- Centos 6.5升级openssl到1.1.0f版本
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz ./config --prefix=/usr/local/openssl share ...
- hlg 1580 tell me the length
智力题,观察上一行,有几个数字. 比如,S[1]=1; S[2]=11; S[3]=21; S[4]=1211; 这样就可以观察出来,序列一是1个1 ---> S[2] = 11 ; 序列二是 ...
- 【JavaScript 2—基础知识点】:数据类型
导读:我发现不管是哪一门语言,都会先介绍其发展,语法规则,数据类型,流程控制等.那么,这次,就介绍一下JavaScript中的数据类型,有些看着眼熟,有些不熟.熟的也不是之前认识的,不熟的,也不见得就 ...
- 【HTML/XML 2】XML基础知识点总结
导读:刚开始看到这个名的时候,还以为会和HTML一样呢,结果看完了资料里的视频,才发现是各有千秋.现在,就对XML的基础知识,做一个总结. 一.总体概述 XML(Extensible Markup L ...
- [BZOJ1583] [Usaco2009 Mar]Moon Mooing 哞哞叫(队列)
传送门 思想有点像蚯蚓那个题 #include <cstdio> #define N 4000001 #define LL long long #define min(x, y) ((x) ...