//緩存
// JWCommon.hspa
// jiawo.net
//調試
// Created by Yin Yi on 15/10/10.orm
// Copyright © 2015年 ZHE JIANG ASUN PROPERTY MANAGEMENT. All rights reserved.圖片
// 全局宏get
#ifndef JWCommon_hstring
#define JWCommon_hit
// 版本io
#define JWDeviceVersion [[UIDevice currentDevice].systemVersion doubleValue]
// rgb顏色
//全局Color Helper
#define HEXCOLORA(rgbValue, a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:a]
#define HEXCOLOR(rgbValue) HEXCOLORA(rgbValue, 1.0)
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f \
alpha:(a)]
#define RGBA(r,g,b,a) (r)/255.0f, (g)/255.0f, (b)/255.0f, (a)
// 當前屏幕尺寸
#define BOUNDS [[UIScreen mainScreen] bounds]
#define WIDTH [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height
#define HEIGHT_64 ([[UIScreen mainScreen] bounds].size.height - 64)
#define BOUNDS_64 (CGRectMake(0,0,WIDTH,HEIGHT_64))
// 屏幕尺寸
#define JWScreemSize [UIScreen mainScreen].bounds.size
#define JWRectMake(x,y,w,h) CGRectMake(JWScreemSize.width * ((x) / 375.0), JWScreemSize.height * ((y) / 667.0), JWScreemSize.width * ((w) / 375.0), JWScreemSize.height * ((h) / 667.0))
#define JWScaleX(x) JWScreemSize.width * ((x) / 375.0)
#define JWScaleY(y) JWScreemSize.height * ((y) / 667.0)
//判斷手機型號
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
// 設備系統版本 > 7.0
#define IOS_VERSION_7_OR_ABOVE ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define IOS_VERSION_8_OR_ABOVE ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IOS_VERSION_9_OR_ABOVE ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
//#define JWScaleW JWScreemSize.width / 375.0
//#define JWScaleH JWScreemSize.height / 667.0
//6P 上的文字設置比6以及6如下尺寸上的文字大一號
#define FontFromIphone(_X_) IPHONE_6P ? [UIFont systemFontOfSize:_X_+1] : [UIFont systemFontOfSize:_X_]
//#define FontFromIphone(_X_) IPHONE_6P ? [UIFont systemFontOfSize:_X_+1] : [UIFont systemFontOfSize:_X_]
#define FontFromIphoneSize(_X_) IPHONE_6P ? (_X_+1) : (_X_)
//固定font 不管在何種iPhone上
#define FontOfInt(_X_) [UIFont systemFontOfSize:_X_]
//NSNull 轉 @""
#define checkNull(__X__) (__X__) == [NSNull null] || (__X__) == nil ? @"" : [NSString stringWithFormat:@"%@", (__X__)]
#define alert(__TITLE__) if (JWDeviceVersion >= 8.0) { \
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:__TITLE__ preferredStyle:UIAlertControllerStyleAlert];\
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; \
double delay = 1; \
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delay *NSEC_PER_SEC); \
dispatch_after(popTime, dispatch_get_main_queue(), ^{ \
[alertController dismissViewControllerAnimated:YES completion:nil]; \
}); \
} else { \
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:__TITLE__ delegate:nil cancelButtonTitle:@"肯定" otherButtonTitles:nil, nil]; \
[alert show]; \
}
// 圖片緩存路徑
#undef DEF_IMAGESCHEPATH
#define DEF_IMAGESCHEPATH [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]
// 單例
#undef DEF_SINGLETON
#define DEF_SINGLETON( __class ) \
+ (__class *)sharedInstance \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \
return __singleton__; \
}
// 調試時候的輸出方法
#ifdef DEBUG
#define JWLog(...) NSLog(__VA_ARGS__)
#else
#define JWLog(...)
#endif
/********普通打印描述(依賴DEBUG開關)********/
#ifdef DEBUG
#define PRINT_STRING(NSString) if (DEBUG) NSLog(@"%@",NSString)
#else
#define PRINT_STRING(NSString)
#endif
#define kNetWorkingTimeoutInterval 20
//共用顏色
#define CommonLightGray HEXCOLOR(0x999999);
#endif /* JWCommon_h */
#define JW15FONT [UIFont systemFontOfSize:15]
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self