/**获取屏幕宽度与高度 导航,tabbar高度*/
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define NavBarHeight self.navigationController.navigationBar.bounds.size.height
#define TabBarHeight self.tabBarController.tabBar.bounds.size.height
#define ViewWidth(v) v.frame.size.width
#define ViewHeight(v) v.frame.size.height
#define ViewX(v) v.frame.origin.x
#define ViewY(v) v.frame.origin.y
/**获取通知中心*/
#define ZSNotificationCenter [NSNotificationCenter defaultCenter]
/**颜色*/
#define ZSRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]//随机色
#define ZSRGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]//rgb
#define ZSGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]//rgba
#define ZSlearColor [UIColor clearColor]//透明色
#define zsColorNavBG [UIColor colorWithHexString:@"0xF8F8F8"]
#define zsColorNavTitle [UIColor colorWithHexString:@"0x323A45"]
#define zsColorTableBG [UIColor colorWithHexString:@"0xFFFFFF"]
#define zsColorTableSectionBg [UIColor colorWithHexString:@"0xF2F4F6"]
#define zsColor222 [UIColor colorWithHexString:@"0x222222"]
#define zsColor666 [UIColor colorWithHexString:@"0x666666"]
#define zsColor999 [UIColor colorWithHexString:@"0x999999"]
#define zsColorDDD [UIColor colorWithHexString:@"0xDDDDDD"]
#define zsColorCCC [UIColor colorWithHexString:@"0xCCCCCC"]
#define zsColorBrandGreen [UIColor colorWithHexString:@"0x3BBD79"]
#define zsColorBrandRed [UIColor colorWithHexString:@"0xFF5846"]
#define YAXMainColor [UIColor colorWithHexString:@"0x29B2BB"] //主题色
//#define YAXMainColor ZSRGBColor(225, 53, 58) //主题色
#define YAXBacColor ZSRGBColor(240, 240, 240) //背景灰色
#define YAXGreen ZSRGBColor(105,176,45)//绿色
#define width(a) (SCREEN_WIDTH/375)*a
#define height(a) (SCREEN_HEIGHT/667)*a
#define YAXButton_HEIGHT 44
#define YAXMAIGN 15
#define YAXHMAIGN width(20)
#define YAXSMAIGN height(20)
#define YAXLMAGIN 10
#define YAXPaddingLeftW width(15)
#define ZSStrFormat(a,b) [NSString stringWithFormat:@"%@%@",a,b]
#define FONT(F) [UIFont systemFontOfSize:F]
#define zsBackButtonFontSize FONT(16) //字体
#define zsNavTitleFontSize FONT(18)
#define zsTitieFontSize FONT(14)
#define zsTipFont FONT(15)
//圆角view
#define CORNERRADIUS(view,radiu) \
view.layer.cornerRadius = radiu;\
view.layer.masksToBounds = YES;\
//默认图片
#define IMAGE_PLACEHOLDER [UIImage imageNamed:@"loadImage"]
#define NavMAXY CGRectGetMaxY(self.navigationController.navigationBar.frame)
#define TabBarY self.tabBarController.tabBar.y
/**Log*/
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d] \n" fmt), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
#define DeBugLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#define NSLog(...) NSLog(__VA_ARGS__);
#define MyNSLog(FORMAT, ...) fprintf(stderr,"[%s]:[line %d行] %s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define DLog(...)
#define DeBugLog(...)
#define NSLog(...)
#define MyNSLog(FORMAT, ...)
#endif
/**强弱引用 http://cc.cocimg.com/api/uploads/20160712/1468319802739618.png*/
#define ZSWeakSelf(type) __weak typeof(type) weak##type = type; //弱
#define ZSStrongSelf(type) __strong typeof(type) type = weak##type; //强
/**view边框*/
#define ZSViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]
/**alertView*/
#define zsTipAlert(_S_, ...) [[[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:(_S_), ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles:nil] show]
/**判断当前的iPhone设备/系统版本*/
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)//判断是否为iPhone
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)//判断是否为iPad
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"]) //判断是否为ipod
#define iPhone5SE [[UIScreen mainScreen] bounds].size.width == 320.0f && [[UIScreen mainScreen] bounds].size.height == 568.0f// 判断是否为 iPhone 5SE
#define iPhone6_6s_7 [[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 667.0f// 判断是否为iPhone 6/6s/7
#define iPhone6Plus_6sPlus_7Plus [[UIScreen mainScreen] bounds].size.width == 414.0f && [[UIScreen mainScreen] bounds].size.height == 736.0f// 判断是否为iPhone 6Plus/6sPlus/7Plus
#define IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]//获取系统版本
#define IOS_VERSION_8_OR_LATER (([[[UIDevice currentDevice] systemVersion] floatValue] >=8.0)? (YES):(NO))//判断 iOS 8 或更高的系统版本
#define kDevice_Is_iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define kDevice_Is_iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define kScaleFrom_iPhone5_Desgin(_X_) (_X_ * (SCREEN_WIDTH/320))
/**判断真机还是模拟器*/
#if TARGET_OS_IPHONE//iPhone Device
#endif
#if TARGET_IPHONE_SIMULATOR//iPhone Simulator
#endif
// 主要单例
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
/**沙盒目录文件*/
#define PathTemp NSTemporaryDirectory()//获取temp
#define PathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]//获取沙盒 Document
#define PathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]//获取沙盒 Cache
/**GCD 的宏定义*/
#define ZSDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);//GCD - 一次性执行
#define ZSDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);//GCD - 在Main线程上运行
#define ZSDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlock);//GCD - 开启异步线程
//class转string
#define StringClass(Class) NSStringFromClass([Class class])
//防止空值赋值
#define NotNullStr(obj,nullObj) obj ? \
([obj isKindOfClass:[NSString class]] ? obj : \
([obj isKindOfClass:[NSNumber class]] ? [(NSNumber *)obj stringValue] : nullObj)) : \
nullObj
网友评论