iOS --- 总结Objective-C中常用的宏定义(持续更新中)
来源:互联网 发布:淘宝男士雪地靴 编辑:程序博客网 时间:2024/05/16 03:00
将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)
1 0
- iOS --- 总结Objective-C中常用的宏定义(持续更新中)
- iOS常用宏定义总结 --Objective-C
- iOS --- 总结Swift中常用的全局函数和extension(持续更新中)
- ios 常用的开源代码(持续更新中)
- Objective-C 开发的一点小总结(持续更新)
- iOS 常用宏定义汇总 【持续更新】
- IOS开发中 常用的宏定义[陆续更新]
- iOS开发中总结的小技巧(持续更新中)
- iOS开发常用代码【持续更新中】
- IOS 常用技术总汇 持续更新中
- PHP 常用 函数总结 持续更新中...
- 总结Swing中常用的方法,持续更新
- 总结Swing中常用的方法,持续更新
- iOS错误总结。。。。。持续更新中
- iOS常见问题总结....持续更新中
- iOS报错总结(持续更新中)
- php常用方法总结(持续更新中)
- [总结]常用正则表达式(持续更新中……)
- Axure 8.0 ······N久以后的再探
- zstuoj (浙理工) 孙壕请一盘青岛大虾呗
- c++ 数据结构 *** 树的部分实现
- npm安装模块err的解决办法之一:cnpm
- Python 格式化输出
- iOS --- 总结Objective-C中常用的宏定义(持续更新中)
- 推送服务 爱心推 的集成步骤
- css控制行数
- UBUNTU 15.04 安装后
- JMockit简单使用(二)
- 10029---CSS 下拉菜单 ,图片廊
- Linux——Vi、Vim编辑器命令基础
- listview 嵌套listview的显示问题
- mysql获取某个表的所有字段名