美文网首页
iPhone12 适配整理

iPhone12 适配整理

作者: 大炮打小鸟 | 来源:发表于2020-10-21 15:00 被阅读0次

新增机型宽高

#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 <Foundation/Foundation.h>
@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";

相关文章

网友评论

      本文标题:iPhone12 适配整理

      本文链接:https://www.haomeiwen.com/subject/bxfemktx.html