在开发过程中,不管是调bug还是什么,log打印是必不可少的,但是有时候后不想让他打印,就要一个个找log很是繁琐
在布局过程中,特别是代码布局,UI控件设置背景颜色,同样必不可少,但其实这些颜色我们只是为了方便布局,很多时候都是要么删掉,要么注掉,很是麻烦
下面是自己开发过程中必备的一些宏定义,
最常用的文本颜色, UI控件的背景颜色开关,log打印的开关【直接定位到某个文件的某一行】
//文本颜色
#define TEXT_FONT_COLOR [UIColor colorWithRed:123 / 255.0 green:127 / 255.0 blue:131 / 255.0 alpha:1.0]//字号
#define k_textFontSize [UIFont systemFontOfSize:14]
//如果需要显示颜色,为 1 , 不需要显示颜色为 0
#if 1
#define k_debugColor [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1.0]
#else
#define k_debugColor [UIColor clearColor]
#endif
//如果不需要log,把1改为0
#if 0
#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif