美文网首页
iOSUI适配YBIBIsIphoneXSeries

iOSUI适配YBIBIsIphoneXSeries

作者: CodingTom | 来源:发表于2020-11-06 14:03 被阅读0次
    
    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; \
    })
    

    相关文章

      网友评论

          本文标题:iOSUI适配YBIBIsIphoneXSeries

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