iOS-为方便项目开发在pch加入一些经常使用宏定义
2024-08-28 19:27:25
1.关于NSLog输出
/**
* 当Xcode为Release时不输出,为Debug时输出
*
* @param ...
*
* @return
*/
#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__) /**
* 打印的时候能够看到类名、方法以及行数
*
*/
//#define NSLog(fmt,...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ## __VA_ARGS__); #else
#define NSLog(...) {}
#endif
2.颜色
#define RGB_Color(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RGB_ColorAlpha(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
#define RGB(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]
#define RGBALPHA(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:(a)]
3.屏幕大小
#define APP_SIZE [UIScreen mainScreen].bounds.size
#define APP_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define APP_HEIGHT ([UIScreen mainScreen].bounds.size.height)
4.系统版本号
#define PPSystemVersionGreaterOrEqualThan(version) ([[[UIDevice currentDevice] systemVersion] floatValue] >= version)
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define SYSTEM_VERSION_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) \
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
(不断更新中)
最新文章
- 使用 python 获取 httpd 程序所占用物理内存
- POJ3398Perfect Service[树形DP 树的最大独立集变形]
- 在android用Get方式发送http请求
- 安装和使用memcached
- Redis实践操作之—— keyspace notification(键空间通知)
- android studio使用发布者证书调试
- Android自己主动化測试解决方式
- codevs4373 窗口==poj2823 Sliding Window
- T4模板使用
- JSON的数据类型
- 夏令营提高班上午上机测试 Day 3 解题报告
- solr研磨之性能调优
- 【转】三个案例带你看懂LayoutInflater中inflate方法两个参数和三个参数的区别
- 用 zotero 管理文献和个人知识库
- Docker笔记——jenkins镜像制作
- RabbitMQ 在 web 页面 创建 exchange, queue, routing key
- 4.1 C++多态的概念及前提条件
- SQL脚本添加删除修改字段
- vim 取消高亮
- echarts 地图 免费离线js,json包分享