切换通话状态栏后,导航栏掉落。并且后面的内容落下高度为20。
我不明白为什么。
图为现场。
导航栏看起来像是掉落了。蓝色条落下。
从 View 层次调试器中看到,我不知道为什么蓝色条与导航栏有一段距离。
这是相关代码。
- (void)viewWillLayoutSubviews{
self.blueBar.translatesAutoresizingMaskIntoConstraints = NO;
[super viewWillLayoutSubviews];
[self.blueBar.topAnchor constraintEqualToAnchor: self.view.topAnchor].active = YES;
[self.blueBar.leadingAnchor constraintEqualToAnchor: self.view.leadingAnchor].active = YES;
[self.blueBar.trailingAnchor constraintEqualToAnchor: self.view.trailingAnchor].active = YES;
[self.blueBar.heightAnchor constraintEqualToConstant: 75].active = YES;
......
}
-(UIView *)blueBar{
if(!_blueBar){
_blueBar = [[UIView alloc] init];
_blueBar.backgroundColor = [UIColor blueColor];
}
return _blueBar;
}
最佳答案
通话时状态栏高度从20变为40。我发现你使用tableView,所以试试这个:
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
更何况,为什么不用主流框架Masonry
呢?
关于ios - 当用户处于通话状态栏时,导航栏布局出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52228415/