05_iPhoneX、iPhone12刘海适配,底部安全区域高度

方法1:

//判断是否为iPhone X
#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

  

//系统导航栏总高度
#define bAllNavTotalHeight (IPHONE_X ? 88 : 64)
// 底部安全区域远离高度 现在使用
#define kBottomSafeHeight   (IPHONE_X?(34):(0))
//状态栏高度
#define STATUSBAR_HEIGHT  (IPHONE_X ? 44 : 20)

方法2:

/**
系统高度,宽度 bounds
*/
#define SCREEN_WIDTH            ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT           ([[UIScreen mainScreen] bounds].size.height)
//是否刘海屏
#define kDevice_Is_iPhoneXScreen  (SCREEN_HEIGHT == 812.0f || SCREEN_HEIGHT == 896.0f || SCREEN_HEIGHT == 844.0f || SCREEN_HEIGHT == 926.0f || SCREEN_HEIGHT == 780.0f)

方法3:

#define TopStatuHeight           [[UIApplication sharedApplication] statusBarFrame].size.height
//系统底部TabBar高度
#define bTabBarHeight          (TopStatuHeight>20?83:49)
//系统导航栏总高度
#define bAllNavTotalHeight     (TopStatuHeight>20?88:64)
// 底部安全区域远离高度
#define kBottomSafeHeight      (TopStatuHeight>20?34:0)

  参考链接:https://blog.csdn.net/smileKH/article/details/110115810

posted @ 2020-12-13 09:08  狼狼a够  阅读(2622)  评论(0编辑  收藏  举报