iOSUI适配YBIBIsIphoneXSeries

2020-11-06  本文已影响0人  CodingTom

BOOL YBIBIsIphoneXSeries(void);
CGFloat YBIBStatusbarHeight(void);
CGFloat YBIBSafeAreaHeight(void);

BOOL YBIBIsIphoneXSeries(void) {
    return YBIBStatusbarHeight() > 20;
}

CGFloat YBIBStatusbarHeight(void) {
    CGFloat height = 0;
    if (@available(iOS 11.0, *)) {
        height = UIApplication.sharedApplication.delegate.window.safeAreaInsets.top;
    }
    if (height <= 0) {
        height = UIApplication.sharedApplication.statusBarFrame.size.height;
    }
    if (height <= 0) {
        height = 20;
    }
    return height;
}

CGFloat YBIBSafeAreaHeight(void) {
    CGFloat bottom = 0;
    if (@available(iOS 11.0, *)) {
        bottom = UIApplication.sharedApplication.delegate.window.safeAreaInsets.bottom;
    }
    return bottom;
}
#define kIsBangsScreen ({\
BOOL isBangsScreen = NO; \
if (@available(iOS 11.0, *)) { \
UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
if (window && [window isKindOfClass:[UIWindow class]]) { \
isBangsScreen = window.safeAreaInsets.bottom > 0; \
} \
}\
isBangsScreen; \
})
上一篇下一篇

猜你喜欢

热点阅读