#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;

ios 日常开发常用宏定义的更多相关文章

  1. Object-C开发常用宏定义

    Object-C开发中宏会将经常用到的系统常量进行封装,方便使用: 1.获取通知中心 #define EYNotificationCenter(name, object, userInfo) [[NS ...

  2. ios开发--常用宏定义(部分转)

    1.release时,屏蔽log #if defined (DEBUG) && DEBUG == 1 #else #define NSLog(...) {}; #endif #if d ...

  3. IOS开发常用宏定义

    //release屏蔽NSLog//放在.pch文件里#ifdef DEBUG #else#define NSLog(...) {};#endif //G.C.D#define BACK(block) ...

  4. 开发常用宏 - iOS

    以下是一些开发中会经常用到的宏,简单的进行了整理,为了今后可以更加方便的使用,从而提升开发的效率,不为此搭进去更多时间. 也希望有大家可以补充,从而使其更加强加! /** * 开发常用宏相关 */ # ...

  5. iOS - 常用宏定义和PCH文件知识点整理

    (一)PCH文件操作步骤演示: 第一步:图文所示: 第二步:图文所示: (二)常用宏定义整理: (1)常用Log日志宏(输出日志详细可定位某个类.某个函数.某一行) //=============== ...

  6. iOS项目开发常用功能静态库

    YHDeveloperTools iOS项目开发常用功能静态库 查看源码 功能方法: 1.字符检查 [NSString checkStringWithType:Email andTargetStrin ...

  7. iOS 日常工作之常用宏定义大全

    转自:http://www.jianshu.com/p/213b3b96cafe 前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了 ...

  8. iOS日常工作之常用宏定义大全

    前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了怎么办?本人在工作中也是如此.所以在这里给大家分享一些常用的宏定义,喜欢的小伙伴可 ...

  9. iOS开发中的常用宏定义

    在iOS开发的过程中合理的使用宏定义能够极大提高编码的速度,下面是一些常用的宏定义,部分内容来自互联网 Log // 调试状态, 打开LOG功能 #ifdef DEBUG #define GLLog( ...

随机推荐

  1. 提供Web相关的个工具类

    package com.opslab.util.web; import com.opslab.util.ConvertUtil;import com.opslab.util.StringUtil; i ...

  2. mysql登录指令

    mysql -h 192.168.1.124 -u root -p -h后加mysql的ip,-u加用户名,-p会弹出输入密码

  3. 【443】Tweets Analysis Q&A

        [Question 01] When converting Tweets info to csv file, commas in the middle of data (i.e. locati ...

  4. ABAP DEMO ALVtree显示BOM层级

    展示效果: *&---------------------------------------------------------------------* *& Report YCX ...

  5. 探索typescript的必经之路-----接口(interface)

    TypeScript定义接口 熟悉编程语言的同学都知道,接口(interface)的重要性不言而喻. 很多内容都会运用到接口.typescrip中的接口类似于java,同时还增加了更灵活的接口类型,包 ...

  6. PHP,Excel导出换行

    // 有id,才算真的有发票数据 if ($v['b_invoice_id']) { $v['b_invoice_info'] = json_decode($v['b_invoice_json'],t ...

  7. LeetCode 14. 最长公共前缀(Longest Common Prefix)

    14. 最长公共前缀 14. Longest Common Prefix 题目描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". Lee ...

  8. [转帖]ARM发布Ethos-N57/N73 NPU、Mali-G57 Valhall GPU和Mali-D37 DPU

    ARM发布Ethos-N57/N73 NPU.Mali-G57 Valhall GPU和Mali-D37 DPU https://www.cnbeta.com/articles/tech/902417 ...

  9. [转帖]kubernetes ingress 在物理机上的nodePort和hostNetwork两种部署方式解析及比较

    kubernetes ingress 在物理机上的nodePort和hostNetwork两种部署方式解析及比较 https://www.cnblogs.com/xuxinkun/p/11052646 ...

  10. Django框架1——视图和URL配置

    三个命令 1.创建一个django项目 在cmd中:django-admin.py startproject project_name D:\python\django_site>django- ...