#pragma mark - 字体、颜色相关

#define kFONT_SIZE(f)            [UIFont systemFontOfSize:(f)]
#define kFONT_BOLD_SIZE(f) [UIFont boldSystemFontOfSize:(f)]
#define kFONT_ITALIC_SIZE(f) [UIFont italicSystemFontOfSize:(f)]
#define kRGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f]
#define kRGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:(a)]
#define kRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
#define kColorWithHex(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]
///============================================================================= #pragma mark - 图片加载
// 加载图片
#define kGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]
// 读取本地图片 (文件名,后缀名)
#define kGetBundleImage(__FILENAME__,__EXTENSION__) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:__FILENAME__ ofType:__EXTENSION__]]
///============================================================================= #pragma mark - 控制台打印
#ifdef DEBUG
#define kLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif
///============================================================================= #pragma mark - 判断数据是否为空
// 字符串是否为空
#define kISNullString(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
// 数组是否为空
#define kISNullArray(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0 ||[array isEqual:[NSNull null]])
// 字典是否为空
#define kISNullDict(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0 || [dic isEqual:[NSNull null]])
// 是否是空对象
#define kISNullObject(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
///============================================================================= #pragma mark - Application相关
// APP对象 (单例对象)
#define kApplication [UIApplication sharedApplication]
// APP对象
#define kAppDelegate (AppDelegate*)[[UIApplication sharedApplication] delegate]
// 主窗口 (keyWindow)
#define kKeyWindow [UIApplication sharedApplication].keyWindow
// NSUserDefaults实例化
#define kUserDefaults [NSUserDefaults standardUserDefaults]
// 通知中心 (单例对象)
#define kNotificationCenter [NSNotificationCenter defaultCenter]
//获取temp
#define kPathTemp NSTemporaryDirectory()
//获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
///============================================================================= #pragma mark - 屏幕坐标、尺寸相关
// 判断是否iPhone X
#define kIS_iPhoneX UIApplication.sharedApplication.statusBarFrame.size.height > 20 : YES : NO
// 屏幕高度
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
// 屏幕宽度
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
// 状态栏高度
#define kStatusBarHeight UIApplication.sharedApplication.statusBarFrame.size.height
// 顶部导航栏高度
#define kNavigationBarHeight 44.f
// 状态栏高度 + 顶部导航栏高度
#define kSafeAreaTopHeight UIApplication.sharedApplication.statusBarFrame.size.height + 44
// 底部安全距离
#define kSafeAreaBottomHeight (IS_iPhoneX ? 34.f : 0.f)
// Tabbar高度
#define kTabbarHeight 49.f // 控件尺寸比例
#define kScreenWidthRate ([[UIScreen mainScreen] bounds].size.width/375.f)
// 实际宽尺寸
#define kSuitWidthSize(size) kScreenWidthRate * (size)
// 控件尺寸比例
#define kScreenHeightRate ([[UIScreen mainScreen] bounds].size.height/667.f)
// 实际高尺寸
#define kSuitHeightSize(size) kScreenHeightRate * (size)
///============================================================================= #pragma mark - 强弱引用
#define kWeakSelf(type) __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;

最新文章

  1. bzoj1734 愤怒的牛
  2. delphi URL 编码的转换
  3. SqlServer性能优化 提高并发性能(八)
  4. 第六节:Vue过滤器的用法和自定义过滤器
  5. 和安全有关的那些事(非对称加密、数字摘要、数字签名、数字证书、SSL、HTTPS及其他)
  6. Robot Framework--04 工作区
  7. js的解析--预处理(三)
  8. VS2010使用附加进程的方式调试IIS中的页面介绍
  9. angularJS自定义 过滤器基础
  10. ## Python中的Package和Jupyter中import包问题
  11. 50行代码实现的高性能动画定时器 raf-interval
  12. Flex 布局实例
  13. python的属性(property)使用
  14. centos7环境下mysql5.7的安装与配置
  15. async get_event_loop
  16. Spring Security教程(三):自定义表结构
  17. 向txt文件中写入内容(覆盖重写与在末尾续写+FileOutputStream与FileWriter)(转发:https://blog.csdn.net/bestcxx/article/details/51381460)
  18. 好强大的页面功能调试(js调试,查找js绑定的事件)值得学习
  19. Digit Division
  20. Ceph中Bufferlist的设计与使用

热门文章

  1. 品优购商城项目(二)mybatis分页插件
  2. osg编译日志-release
  3. Spring Boot 使用MockMvc对象模拟调用Controller
  4. springboot 整合 Froala Editor 3
  5. Delphi 调用控件的过程,初学者都想知道
  6. LODOP中设置设置图片平铺水印,超文本透明
  7. SqlServer里,一条sql进行递归删除
  8. cordon、drain、delete node区别
  9. vue 跨域简记
  10. SpringCloud用Zookeeper做服务注册与发现中心代码实现