宏定义
来源:互联网 发布:阿里云 商标注册 编辑:程序博客网 时间:2024/05/19 20:37
1.首次启动判断:
#define First_Launched @"firstLaunch"
2.ios7系统判断:
#define IsIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >=7.0 ? YES : NO)
3.判断是否Retina屏、是否IPhone5、是否IPad
#define isRetina ([UIScreen instancesRespondToSelector:
@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960),
[[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:
@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136),
[[UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
4.加载图片宏:
#define LOADIMAGE(file,type) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:type]]
5.rgb颜色转换(16进制->10进制)
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
6.设置颜色RGB
#define COLOR(R, G, B, A)
[UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
7.去除"-(id)performSelector:(SEL)aSelector withObject:(id)object;"的警告
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义
- 宏定义,#,##
- 宏定义
- 宏定义
- 宏定义
- [重写开源框架源码]SwipeBackLayout实现全屏滑动
- 蓝桥杯 算法训练 未名湖边的烦恼
- 发现一个好东西
- GetCharPos
- 自主研发异步通信框架Minma(支持长连接和短连接)
- 宏定义
- zzulioj--1712--Monty Hall problem(蒙提霍尔问题)
- Direct3d & opengl & 3d max的配置和使用
- failed to resolve com.android.support:appcompat-v7:23+ 解决方法
- 最大流学习笔记
- 通过SQL Server 2008数据库复制实现数据库同步备份
- nyoj--514--1的个数(贪心)
- 【ZYNQ-7000开发之八】OLED的驱动
- jquery中focus()函数实现当对象获得焦点后自动把光标移到内容最后