//单例
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)shared##classname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [[self alloc] init]; \
} \
} \
\
return shared##classname; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [super allocWithZone:zone]; \
return shared##classname; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
}
//根据比例按宽度计算高度
#define getHeightByRate(oriWidth,oriHeight,newWidth) newWidth*oriHeight/oriWidth
//根据比例按高度计算宽度
#define getWidthByRate(oriWidth,oriHeight,newHeight) newHeight*oriWidth/oriHeight
//根据宽度计算在屏幕水平居中的X坐标开始位置
#define getCenterXByWith(oriWidth) (SCREEN_BOUNDS.size.width-oriWidth)/2
//判断字符串是否为空
#define NSStringIsNullOrEmpty(string) ({NSString *str=(string);(str==nil || [str isEqual:[NSNull null]] || str.length == 0 || [str isKindOfClass:[NSNull class]] || [[str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] isEqualToString:@""])?YES:NO;})
//系统类型
#define isbeforeIOS7 ([[[UIDevice currentDevice]systemVersion]floatValue] < 7.0?YES:NO)
#define isIOS7AndLater ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0?YES:NO)
//ios系统版本
#define ios8 [[[UIDevice currentDevice] systemVersion] floatValue] >=8.0f
#define ios7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f) && ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0f)
#define ios6 [[[UIDevice currentDevice] systemVersion] floatValue] < 7.0f
#define ios7AndLater [[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0f
//方正黑体简体字体定义
#define FONT(F) [UIFont fontWithName:@"FZHTJW--GB1-0" size:F]
//G-C-D
#define GCD_BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define GCD_MAIN(block) dispatch_async(dispatch_get_main_queue(),block)