当前位置:首页 > 操作系统 > Ios

iOS 安全区域适配

    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGFloat rectStatusHeight = rectStatus.size.height;
    NSLog(@"status width - %f", rectStatus.size.width); // 宽度
    NSLog(@"status height - %f", rectStatus.size.height);  // 高度
    [rootView mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11.0, *)) {
            make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
            make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.top.equalTo(@(rectStatusHeight));
            make.left.right.bottom.equalTo(0);
        }
    }];

 

原文:https://www.cnblogs.com/sunyaxue/p/10329315.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!