//----------------------圖片相關(guān)----------------------------
//讀取本地圖片
#define LoadImage(file,type) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:type]]
#define LoadPNGImage(file) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:@"png"]]
//定義UIImage對(duì)象
#define ImageNamed(name) [UIImage imageNamed:name]
//可拉伸的圖片
#define ResizableImage(name,top,left,bottom,right) [[UIImage imageNamed:name] resizableImageWithCapInsets:UIEdgeInsetsMake(top,left,bottom,right)]
#define ResizableImageWithMode(name,top,left,bottom,right,mode) [[UIImage imageNamed:name] resizableImageWithCapInsets:UIEdgeInsetsMake(top,left,bottom,right) resizingMode:mode]
//圖片尺寸
#define CustomSizeImage(url,width,height) [NSString stringWithFormat:@"%@?imageView2/1/w/%d/h/%d",url,width,height]
//----------------------顏色相關(guān)---------------------------
// rgb顏色轉(zhuǎn)換(16進(jìn)制->10進(jìn)制)
#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]
// 獲取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 FONT(F) [UIFont systemFontOfSize:F]
//[UIFont fontWithName:@"Source Han Sans CN" size:F]
#define FONTSYSTEMBOLD(F) [UIFont boldSystemFontOfSize:F]
//----------------------系統(tǒng)設(shè)備相關(guān)----------------------------
//獲取Window
#define WINDOW [UIApplication sharedApplication].keyWindow
//獲取設(shè)備屏幕尺寸
#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)
#define ScreenHeight ([UIScreen mainScreen].bounds.size.height)
#define APP_WIDTH [[UIScreen mainScreen]applicationFrame].size.width
#define APP_HEIGHT [[UIScreen mainScreen]applicationFrame].size.height
//獲取系統(tǒng)版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]
#define isIOS4 ([[[UIDevice currentDevice] systemVersion] intValue]==4)
#define isIOS5 ([[[UIDevice currentDevice] systemVersion] intValue]==5)
#define isIOS6 ([[[UIDevice currentDevice] systemVersion] intValue]==6)
#define isIOS7 ([[[UIDevice currentDevice] systemVersion] intValue]==7)
#define isIOS8 ([[[UIDevice currentDevice] systemVersion] intValue]==8)
#define isIOS9 ([[[UIDevice currentDevice] systemVersion] intValue]==9)
#define isAfterIOS4 ([[[UIDevice currentDevice] systemVersion] intValue]>4)
#define isAfterIOS5 ([[[UIDevice currentDevice] systemVersion] intValue]>5)
#define isAfterIOS6 ([[[UIDevice currentDevice] systemVersion] intValue]>6)
#define isAfterIOS7 ([[[UIDevice currentDevice] systemVersion] intValue]>7)
#define isAfterIOS8 ([[[UIDevice currentDevice] systemVersion] intValue]>8)
#define isIOS4OrAfter ([[[UIDevice currentDevice] systemVersion] intValue]>=4)
#define isIOS5OrAfter ([[[UIDevice currentDevice] systemVersion] intValue]>=5)
#define isIOS6OrAfter ([[[UIDevice currentDevice] systemVersion] intValue]>=6)
#define isIOS7OrAfter ([[[UIDevice currentDevice] systemVersion] intValue]>=7)
#define isIOS8OrAfter ([[[UIDevice currentDevice] systemVersion] intValue]>=8)
//獲取當(dāng)前語言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//判斷是否 Retina屏、設(shè)備是否iphone 5毙玻、是否是iPad
#define isIphone6OrAfter [[UIScreen mainScreen] bounds].size.width > 320.0f
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//判斷是真機(jī)還是模擬器
#if TARGET_OS_IPHONE
//iPhone Device
#endif
#if TARGET_IPHONE_SIMULATOR
//iPhone Simulator
#endif
//----------------------視圖相關(guān)----------------------------
//得到視圖的left top的X,Y坐標(biāo)點(diǎn)
#define VIEW_TX(view) (view.frame.origin.x)
#define VIEW_TY(view) (view.frame.origin.y)
//得到視圖的right bottom的X,Y坐標(biāo)點(diǎn)
#define VIEW_BX(view) (view.frame.origin.x + view.frame.size.width)
#define VIEW_BY(view) (view.frame.origin.y + view.frame.size.height)
//得到視圖的尺寸:寬度豌蟋、高度
#define VIEW_W(view)? (view.frame.size.width)
#define VIEW_H(view)? (view.frame.size.height)
//得到frame的X,Y坐標(biāo)點(diǎn)
#define FRAME_X(frame)? (frame.origin.x)
#define FRAME_Y(frame)? (frame.origin.y)
//得到frame的寬度、高度
#define FRAME_W(frame)? (frame.size.width)
#define FRAME_H(frame)? (frame.size.height)
//---------------------打印日志--------------------------
//打印Frame
#define LogFrame(frame) NSLog(@"Frame[X=%.1f,Y=%.1f,W=%.1f,H=%.1f",frame.origin.x,frame.origin.y,frame.size.width,frame.size.height)
//打印Size
#define LogSize(size) NSLog(@"Size[W=%.1f,H=%.1f",size.width,size.height)
//打印Point
#define LogPoint(point) NSLog(@"Point[X=%.1f,Y=%.1f]",point.x,point.y)
//打印Log
#define Log(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
//file
//讀取文件的文本內(nèi)容,默認(rèn)編碼為UTF-8
#define FileString(name,ext)? ? ? ? ? ? [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)] encoding:NSUTF8StringEncoding error:nil]
#define FileDictionary(name,ext)? ? ? ? [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)]]
#define FileArray(name,ext)? ? ? ? ? ? [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(name) ofType:(ext)]]
//G-C-D
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)
//Alert
#define ALERT(msg) [[[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:@"確定" otherButtonTitles:nil] show]
//----------------------程序相關(guān)----------------------------
// 應(yīng)用程序托管
#define AppDelegateInstance ((AppDelegate*)([UIApplication sharedApplication].delegate))
// 本地存儲(chǔ)
#define UserDefaults [NSUserDefaults standardUserDefaults]
// 通知中心
#define NotificationCenter [NSNotificationCenter defaultCenter]
//由角度獲取弧度 有弧度獲取角度
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(radian) (radian*180.0)/(M_PI)
//字符串
#define AppendString(string,addstring) [string stringByAppendingString:addstring]
//----------------------內(nèi)存相關(guān)----------------------------
#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif
#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif
// block self
#define WEAKSELF typeof(self) __weak weakSelf = self;
#define STRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf;
//釋放一個(gè)對(duì)象
#define SAFE_DELETE(P) if(P) { [P release], P = nil; }
#define SAFE_RELEASE(x) [x release];x=nil
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)