black_pearl
black_pearl

Reputation: 2699

NavigationBar Layout has an exception when user has in call status bar

After I toggle in-call status bar, the navigation bar drops. And the content behind falls a height of 20 .

I can not figure out why.

The picture shows the scene.

1

Looks like the navigation bar drops. And the blue bar falls.

Seen from the view hierarchy debugger, I do not know why the blue bar has a distance from the navigation bar.

2

Here is the relevant code.

- (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;
}

Upvotes: 0

Views: 26

Answers (1)

无夜之星辰
无夜之星辰

Reputation: 6158

The status bar height change from 20 to 40 when in-call.And I found you use tableView,so try this:

if (@available(iOS 11.0, *)) {
    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
    self.automaticallyAdjustsScrollViewInsets = NO;
}

What's more,why not use mainstream frameworkMasonry?

Upvotes: 1

Related Questions