iOS修行---宏定义收集整理

1.UIColor--16进制

#define UIColorFromHex(s,alp)  [UIColor colorWithRed:(((s & 0xFF0000) >> 16))/255.0 green:(((s &0xFF00) >>8))/255.0 blue:((s &0xFF))/255.0 alpha:alp]

2.屏幕尺寸

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height

3.状态栏高度和导航栏高度

#define StatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height;
#define NavBarHeight self.navigationController.navigationBar.frame.size.height;

4.设置随机颜色

#define QSRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]


5.弱引用/强引用

#define QSWeakSelf(type)  __weak typeof(type) weak##type = type;
#define QSStrongSelf(type)  __strong typeof(type) type = weak##type;

6.自定义NSLog

#ifdef DEBUG
#define QSLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define QSLog(...)

#endif


7.系统版本

#define iOSversionFloat [[[UIDevice currentDevice] systemVersion] floatValue]








  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值