还是觉得丢到博客上 找起来方便 :p
打印
<code>
#ifndef LOG_ON
#define LOG_ON //LOG_OFF
#endif
</code>
#ifdef LOG_ON
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
更改 第二行的 LOG_ON/LOG_OFF切换
颜色
随机色 先丢上来 回头决定留哪个
#define RandomColor [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1.0]
#define RandomColor1 [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
RGB颜色
#define UIColorFromRGB(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]
RGBA颜色
#define UIColorFromRGBA(rgbValue) [UIColor \ colorWithRed:((float)((rgbValue & 0xFF000000) >> 24))/255.0 \ green:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ blue:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ alpha:((float)(rgbValue & 0xFF))/255.0]
版本
当前版本
#define CURRENT_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
大于等于7.0的ios版本
#define iOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
大于等于8.0的ios版本
#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
尺寸
屏幕
#define SCREENRECT [[UIScreen mainScreen] bounds]
#define SCRHEIGHT [[UIScreen mainScreen]bounds].size.height
#define SCRWIDTH [[UIScreen mainScreen]bounds].size.width
tabbar和navbar
#define TABBAR_HEIGHT 49
#define NAVBAR_HEIGHT ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0 ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:44):(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:64))
文件目录
#define kPathTemp NSTemporaryDirectory()
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
功能
获取系统时间戳
#define getCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]
判断是否为空
#define DT_IsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length]<1 ? YES : NO )
先这样 后面后继续补充