// --------------屏幕宽高--------------------
#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)
#define Screenheight ([UIScreen mainScreen].bounds.size.height)
// button边框
#define BUTTON_BODER(button,width,color)\
button.layer.borderColor = color.CGColor;\
button.layer.borderWidth = width;
// 弱引用 weakSelf
#define K_WEAK_SELF __weak __typeof(&*self)weakSelf = self
// button添加点击事件
#define BTN_MSG_FUNC(btn,func) [btn addTarget:self action:@selector(func) forControlEvents:UIControlEventTouchUpInside]
// 图片添加点击事件
#define IMAGE_FUNC(image,func) [image setUserInteractionEnabled:YES];\
[image addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(func)]];
/** 右按钮 文字 */
#define Right_Item_text(name,rightAction)\
UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithTitle:name style:(UIBarButtonItemStyleDone) target:self action:@selector(rightAction)];\
self.navigationItem.rightBarButtonItem = item;
/** 右按钮 图片 */
#define Right_Item_Image(Imagename,selector)\
UIBarButtonItem *litem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:Imagename] style:(UIBarButtonItemStyleDone) target:self action:@selector(selector)];\
self.navigationItem.rightBarButtonItem = litem;
// 视图旋转
#define VIEW_Transform(view,Transform)\
[view setTransform:CGAffineTransformMakeRotation(M_PI * Transform)];
// 圆角宏 Radius传角度
#define VIEW_RADIUS(View, Radius)\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]
// 圆形
#define VIEW_YuanJiao(View)\
[View.layer setCornerRadius:(View.frame.size.height/2)];\
[View.layer setMasksToBounds:YES]
//----------------------图片---------------------------
//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
//定义UIImage对象
#define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]
//全屏背景图
#define BACK_IMAGE(view,imageName)\
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];\
imageView.frame=CGRectMake(0, 0, Main_Screen_Width, Main_Screen_Height);\
[view addSubview:imageView];\
[view sendSubviewToBack:imageView];
//背景图+frame
#define BACK_IMAGE_FRAME(view,imageName,cgrctFrame)\
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];\
imageView.frame=cgrctFrame;\
[view addSubview:imageView];\
[view sendSubviewToBack:imageView];
//----------------------颜色---------------------------
// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
// 随机色
#define WZYRandomColor [UIColor colorWithRed:arc4random_uniform(256) /255.0 green:arc4random_uniform(256) /255.0 blue:arc4random_uniform(256) /255.0 alpha:1]
//随机色透明度
#define WZYRandomColorWithAlpha(a) [UIColor colorWithRed:arc4random_uniform(256) /255.0 green:arc4random_uniform(256) /255.0 blue:arc4random_uniform(256) /255.0 alpha:(a)]
//清除背景色
#define CLEARCOLOR [UIColor clearColor]
// 按照像素处理值自适应屏幕用
#define SNRealValue(value) ((value)/375.0f*[UIScreen mainScreen].bounds.size.width)
//________________系统相关____________________
//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
//#define IOS8 ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0 && [[UIDevice currentDevice].systemVersion doubleValue] < 9.0)
#define IOS8_10 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 && [[UIDevice currentDevice].systemVersion doubleValue] < 10.0)
#define IOS10 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0)
//获取当前语言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
/** 是否ipad */
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//单例化一个类
#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; \
}
//----------------------颜色类---------------------------
// 16进制颜色
#define UIColorFromValue16(value16) [UIColor \
colorWithRed:((float)((value16 & 0xFF0000) >> 16))/255.0 \
green:((float)((value16 & 0xFF00) >> 8))/255.0 \
blue:((float)(value16 & 0xFF))/255.0 alpha:1.0]
// aqua 浅蓝
#define qianLanColor [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000]
// sky 天蓝
#define tianLanColor [UIColor colorWithRed:0.400 green:0.800 blue:1.000 alpha:1.000]
// 浅红
#define qianHongColor [UIColor colorWithRed:1.000 green:0.400 blue:0.400 alpha:1.000]
// 蓝紫色
#define lanZiColor [UIColor colorWithRed:0.400 green:0.400 blue:1.000 alpha:1.000]
#define hui1Color [UIColor colorWithWhite:0.902 alpha:1.000]// 1灰
#define hui2Color [UIColor colorWithWhite:0.800 alpha:1.000]// 2灰
#define hui3Color [UIColor colorWithWhite:0.702 alpha:1.000]// 3灰
#define hui4Color [UIColor colorWithWhite:0.600 alpha:1.000]// 4灰
#define hui5Color [UIColor colorWithWhite:0.502 alpha:1.000]// 5灰
#define hui6Color [UIColor colorWithWhite:0.498 alpha:1.000]// 6灰
#define hui7Color [UIColor colorWithWhite:0.400 alpha:1.000]// 7灰
#define hui8Color [UIColor colorWithWhite:0.298 alpha:1.000]// 8灰
#define hui9Color [UIColor colorWithWhite:0.200 alpha:1.000]// 9灰
#define hui10Color [UIColor colorWithWhite:0.098 alpha:1.000]// 10灰
#define dateFormatDefine @"yyyy-MM-dd HH:mm:ss"