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.height3.状态栏高度和导航栏高度
#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]
iOS开发技巧汇总
本文介绍了iOS开发中的一些实用技巧,包括UIColor从16进制转换的方法、获取屏幕尺寸的宏定义、状态栏及导航栏高度的获取方式、生成随机颜色的函数、弱引用与强引用的宏定义、自定义NSLog函数以及获取系统版本的方法。

被折叠的 条评论
为什么被折叠?



