Search code examples
iosswiftxcodeautolayoutsafearealayoutguide

UINavigationBar collapses automatically when contentInset is set


I've made simple project with single view controller inside UINavigationController. In the view controller I've added UITableView and set contentInset.top = 52.

When I push some view controller in navigation stack and pop back, large navigation bar collapses as shown on image below.

But if I don't set contentInset, that everything works correctly.

enter image description here


Solution

  • You should activate Safe Area Relative Margins and Safe Area Layout Guide: Layout Margins

    Also in interface builder pin table view to Superview instead of Safe Area: enter image description here