iOS iPhone12&其他机型适配

iOS iPhone12&其他机型适配_第1张图片
机型

// 判断是否是ipad
#define JH_isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
// 判断iPhone4系列
#define JH_isiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPhone5系列
#define JH_isiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPhone6系列
#define JS_isiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
//判断iphone6+系列
#define JH_isiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPhoneX
#define JH_isIPhone_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPHoneXr | 11
#define JH_isIPhone_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPhoneXs | 11Pro
#define JH_isIPhone_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)
// 判断iPhoneXs Max | 11ProMax
#define JH_isIPhone_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)

//判断iPhone12_Mini
#define JH_isIPhone_iPhone12_Mini ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1080, 2340), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)

//判断iPhone12 | 12Pro
#define JH_isIPhone_iPhone12 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1170, 2532), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)

//判断iPhone12 Pro Max
#define JH_isIPhone_iPhone12_ProMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1284, 2778), [[UIScreen mainScreen] currentMode].size) && !JH_isPad : NO)

//x系列
#define JH_isIPhone_IPhoneX_All (JH_isIPhone_X || JH_isIPhone_Xr || JH_isIPhone_Xs || JH_isIPhone_Xs_Max || JH_isIPhone_iPhone12_Mini || JH_isIPhone_iPhone12 || JH_isIPhone_iPhone12_ProMax)

#define Height_StatusBar ((JH_isIPhone_X == YES || JH_isIPhone_Xr == YES || JH_isIPhone_Xs == YES || JH_isIPhone_Xs_Max == YES || JH_isIPhone_iPhone12_Mini == YES) ? 44.0 : 20.0)

#define Height_NavBar ((JH_isIPhone_Xr == YES || JH_isIPhone_Xs == YES || JH_isIPhone_Xs_Max == YES || JH_isIPhone_iPhone12_Mini == YES) ? 88.0 : (JH_isIPhone_X == YES) ? 92 : (JH_isIPhone_iPhone12 == YES || JH_isIPhone_iPhone12_ProMax == YES) ? 91 : 64.0)

#define Height_TabBar ((JH_isIPhone_IPhoneX_All == YES) ? 83.0 : 49.0)

#define Height_bottomSafeArea (JH_isIPhone_IPhoneX_All == YES ? 34.0 : 0.0)

/// 等比例适配 以当前设计图为模板
//812.0f----375.0f
#define SCREEN_WIDTH_BILI (SCREEN_WIDTH/375.0f)
#define Width_Real(a) a*SCREEN_WIDTH_BILI

#define SCREEN_HEIGHT_BILI (SCREEN_HEIGHT/812.0f)
#define Height_Real(a) a*SCREEN_HEIGHT_BILI

查看

NSLog(@"状态栏高度=%f",[[UIApplication sharedApplication] statusBarFrame].size.height);

NSLog(@"导航栏高度+状态栏高度=%f",self.navigationController.navigationBar.frame.size.height + [[UIApplication sharedApplication] statusBarFrame].size.height);

NSLog(@"Tabbar高度=%f",self.tabBarController.tabBar.bounds.size.height);

你可能感兴趣的:(iOS iPhone12&其他机型适配)