// screen

 

#define kWidth  [UIScreen mainScreen].bounds.size.width

#define kHeight [UIScreen mainScreen].bounds.size.height

#define kWindow [UIApplication sharedApplication].keyWindow

 

 

//iPhone X 适配

/**

 *  替换 64px →kTopHeight

 *  替换 49px →kTabBarHeight

 */

#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height

#define kNavBarHeight 44.0

#define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height>20?83:49)

#define kTopHeight (kStatusBarHeight +kTabBarHeight)

 

 

//设备型号

 

#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 iPhone6PlusScale ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

 

//iPhone X or XS

#define iPhoneX     (DEVICE_WIDTH == 375.f && DEVICE_HEIGHT == 812.f)

//iPhone XR or XS Max

#define iPhoneXR    (DEVICE_WIDTH == 414.f && DEVICE_HEIGHT == 896.f)

#define iPhoneMaxScreen (DEVICE_WIDTH >= 375.f && DEVICE_HEIGHT >= 812.f)

//底部虚拟home键高度 一般用于最底部view到底部的距离

#define VirtualHomeHeight (iPhoneMaxScreen ? 34.f : 0.f)

//顶部适配的话 系统有参数可以直接获取到

#define STATUS_BAR_FRAME [[UIApplication sharedApplication] statusBarFrame]

///系统版本是否大于或等于输入版本

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

 

 

//storyboard

#define GetSbVc(sbName ,VcName)     [[UIStoryboard storyboardWithName:sbName bundle:nil] instantiateViewControllerWithIdentifier:VcName]

 

/**

 16位颜色值

 

 **/

#define HEXColor(hexValue,alphaValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:alphaValue]

 

#define RGB(R,G,B,A)  [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

 

#define HxRGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1]  

 

#define UIColorFromHex(hex) [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0 green:((float)((hex & 0xFF00) >> 8))/255.0 blue:((float)(hex & 0xFF))/255.0 alpha:1.0]