美文网首页
iOS常用宏定义

iOS常用宏定义

作者: dpplh | 来源:发表于2016-06-01 11:07 被阅读25次

NSLog

#ifdef DEBUG
#   define DLog(...) NSLog(__VA_ARGS__)
#else
#   define DLog(...)
#endif

Dealloc

#define DEALLOC -(void)dealloc{NSLog(@"%@ dealloc", NSStringFromClass([self class]));}

Size

#define kSCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define kSCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height

#define kSTATUS_BAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height

#define FIX_SIZE(num) ((num) * kSCREEN_WIDTH /320)
#define FIX_FONT_SIZE(size) kSCREEN_WIDTH <375? ((size +4.0) /2.0) : kSCREEN_WIDTH ==375? ((size +8.0) /2.0) : ((size +12.0) /2.0)
#define Font(size) [UIFont systemFontOfSize:FIX_FONT_SIZE(size)]

#define kNAVI_BAR_HEIGHT 44.0
#define kSTATUS_NAVI_BAR_HEIGHT 64.0

Color

#define RGBA(r, g, b, a) [UIColor colorWithRed:(r) / 255.0 green:(g) / 255.0 blue:(b) / 255.0 alpha:(a)]
#define RGB(r, g, b) RGBA(r, g, b, 255)

#define HEX_RGBA(rgba) RGBA(((rgba) & 0xff000000) >> 24, \
((rgba) & 0x00ff0000) >> 16, \
((rgba) & 0x0000ff00) >> 8, \
((rgba) & 0x000000ff) >> 0)

#define HEX_RGB(rgb) HEX_RGBA(((rgb) << 8) + 0xff)

相关文章

  • iOS常用宏定义

    打印日志的几种写法 推荐文章iOS 日常工作之常用宏定义大全iOS常用宏定义 结束语 到这里就结束了,如若不懂的话...

  • iOS-常用宏定义

    [转自:iOS常用宏定义][http://www.cocoachina.com/ios/20161207/1831...

  • iOS 常用宏定义

    iOS 开发中使用一些常用宏定义可以大大提高开发效率,提高代码的重用性.以下是一些常用的宏定义: 像这些宏定义,在...

  • IOS NSLog宏定义

    IOS NSLog宏定义 标签(空格分隔): IOS IOS NSLog宏定义 宏定义NSLog方法,不用加";"...

  • iOS常用宏定义

    1.UI元素 //NavBar高度#defineNAVIGATIONBAR_HEIGHT 44//StatusBa...

  • iOS常用宏定义

    字符串是否为空 #define kStringIsEmpty(str) ([str isKindOfClass:[...

  • iOS常用宏定义

    字符串是否为空 数组是否为空 字典是否为空 是否是空对象 获取屏幕宽度与高度 ( " \ ":连接行标志,连接上下...

  • iOS常用宏定义

  • iOS常用宏定义

    #ifndef MacroDefinition_h #define MacroDefinition_h //---...

  • iOS常用宏定义

    整理 //常用宏定义 //是否为V以上系统 #define IOS(V) [[[UIDevice currentD...

网友评论

      本文标题:iOS常用宏定义

      本文链接:https://www.haomeiwen.com/subject/gfjhdttx.html