iPhone12|iPhone12 适配整理
新增机型宽高
#define WH_ISIPHONE12MINI ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1080, 2340), [[UIScreen mainScreen] currentMode].size) : NO)
#define WH_ISIPHONE12 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1170, 2532), [[UIScreen mainScreen] currentMode].size) : NO)
#define WH_ISIPHONE12MAX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1284, 2778), [[UIScreen mainScreen] currentMode].size) : NO)#define WH_ISIPHONELH (WH_ISIPHONEX||WH_ISIPHONEXMax||WH_ISIPHONEXR||WH_ISIPHONE12MINI||WH_ISIPHONE12||WH_ISIPHONE12MAX)
#define Tabbar_Height (WH_ISIPHONELH?83:49) //tabbar高度
状态栏改变适配(不能写死,因为有44、47、48不等)
#define WH_ISIOS13 [[[UIDevice currentDevice] systemVersion] floatValue] >= 13.0//ios13以上
#define Nav_Height ((WH_ISIOS13?([UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame.size.height):([[UIApplication sharedApplication] statusBarFrame].size.height))+44) //导航栏高度
或简洁的写
// 状态栏高度
#define kStatusBarHeight [ZXKHelpTools getStatusBarHight]
// 导航栏高度
#define Nav_Height(kStatusBarHeight + 44)
.h
#import
@interface ZXKHelpTools : NSObject
+ (CGFloat)getStatusBarHight;
@end
.m
#import "ZXKHelpTools.h"@implementation ZXKHelpTools
+ (CGFloat)getStatusBarHight {
float statusBarHeight = 0;
if (@available(iOS 13.0, *)) {
UIStatusBarManager *statusBarManager = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
statusBarHeight = statusBarManager.statusBarFrame.size.height;
}
else {
statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
}
return statusBarHeight;
}
@end
新增机型
if ([deviceString isEqualToString:@"iPhone13,1"]) return @"iPhone 12 mini";
if ([deviceString isEqualToString:@"iPhone13,2"]) return @"iPhone 12";
if ([deviceString isEqualToString:@"iPhone13,3"]) return @"iPhone 12 Pro";
if ([deviceString isEqualToString:@"iPhone13,4"]) return @"iPhone 12 Pro Max";
推荐阅读
- 20190302|20190302 复盘翻盘
- 【韩语学习】(韩语随堂笔记整理)
- 三国谋略22(找准你的定位)
- 2019-08-29|2019-08-29 iOS13适配那点事
- Android6.0~9.0适配
- 程序员|【高级Java架构师系统学习】毕业一年萌新的Java大厂面经,最新整理
- CocoaAsyncSocket|CocoaAsyncSocket (GCDAsyncSocket)适配IPv6
- iOS|iOS runtime应用整理
- 整理师囍囍的日记|整理师囍囍的日记 day19
- 整理大部分Eslint规则