1

这次崩溃:

make.top.left.right.equalTo(self.view.mas_safeAreaLayoutGuide);

但这没关系:

make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);

为什么?我用砖石

这是主要代码:

- (void)configView {
    self.view.backgroundColor = kColor666;
    UIView *headView = [UIView new];
    headView.backgroundColor = kColorWhite;
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
    if (@available(iOS 11.0, *)) {
        make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop); //ok
        make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);   //ok
        make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight); //ok
        make.top.left.right.equalTo(self.view.mas_safeAreaLayoutGuide);   //crash
    } else {
        make.top.equalTo(self.mas_topLayoutGuide);
        make.left.right.equalTo(self.view);
    }
    make.height.mas_equalTo(120);
    }];
}

似乎没有错。我只想写更少的代码。

4

0 回答 0