开发中经常用到的常量定义(随时更行):

与UIView相关

//获取View的frame属性
#define GetViewWidth(view) view.frame.size.width
#define GetViewHeight(view) view.frame.size.height
#define GetViewX(view) view.frame.origin.x
#define GetViewY(view) view.frame.origin.y

与屏幕相关

//屏幕尺寸(宽高)常量
#define GetScreenWidth [[UIScreen mainScreen] bounds].size.width
#define GetScreenHeight [[UIScreen mainScreen] bounds].size.height

与系统版本相关

//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define IOS6 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
#define IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 8.0)
#define IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 9.0)
#define IOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 10.0)

与UIColor相关

//取得对应的UIcolor
#define UIColorFromRGB(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f]
#define UIColorFromRGBA(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A]
#define UIColorFromHex(Hex) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:1.0f]
#define UIColorFromHexA(Hex, A) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:A]

与GCD相关

//只运行一次的GCD
#define DISPATCH_ONCE_BLOCK(Block) static dispatch_once_t onceToken; dispatch_once(&onceToken, Block); //在Main线程上运行的GCD
#define DISPATCH_ON_MAIN_THREAD(Block) dispatch_async(dispatch_get_main_queue(), Block); //在Global Queue上运行的GCD
#define DISPATCH_ON_GLOBAL_QUEUE_HIGH(Block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), Block);
#define DISPATCH_ON_GLOBAL_QUEUE_DEFAULT(Block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), Block);
#define DISPATCH_ON_GLOBAL_QUEUE_LOW(Block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), Block);
#define DISPATCH_ON_GLOBAL_QUEUE_BACKGROUND(Block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), Block);

与弧度、角度相关

//用角度生成弧度
#define RadiansFromDegrees(Degress) (M_PI * (Degress) / 180.0)

与UIImage相关

//获取图片资源
#define GetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

最新文章

  1. 这可能是由于服务终结点绑定未使用 HTTP 协议造成的 .这还可能是由于服务器中止了 HTTP 请求上下文
  2. iOS获取设备唯一标识的8种方法
  3. Linux C 中 fork() 函数详解
  4. 常见http status code
  5. runtime学习实战一:类的属性进行归档解档
  6. luogu[1279]字串距离
  7. android提示框
  8. iOS 库文件制作
  9. We&#39;re Hiring A Software Tester
  10. 人们的Live Meeting系列 (floyd)
  11. matlab 利用while循环计算平均值和方差
  12. 像 npm 一样在 Andriod 项目中引入 Gradle 依赖
  13. Linux发行版 CentOS6.5下删除分区操作
  14. BAT齐聚阿里安全-ASRC生态大会:呼吁联合共建网络安全白色产业链
  15. Android Studio 3.0+ Annotation processors must be explicitly declared now
  16. 关于Oracle的44951事件
  17. vs2017 .net core 项目调试浏览器网页闪退Bug
  18. redis epoll 原理梗概
  19. 2emq服务器压力测试(无用)
  20. openssl 连接 https(nginx)

热门文章

  1. [翻译]python3中新的字符串格式化方法-----f-string
  2. spring——AOP原理及源码(二)
  3. Web渗透基础小总结
  4. 深度解析互联网大厂面试难题自定义@EnableXX系列
  5. 动态构造任意复杂的 Linq Where 表达式
  6. 关于HTTP那些事
  7. 使用HBuilder开发移动APP
  8. 【每日一包0018】fecha
  9. JZOJ 5286. 【NOIP2017提高A组模拟8.16】花花的森林 (Standard IO)
  10. JZOJ 1774. 合并果子 (Standard IO)