iOS 11 black bar appears on navigation bar when pushing view controller

Viewed 7388

I have this weird bug only in iOS 11, in lower iOS, everything works fine. The problem is that whenever pushing to a view controller, there is a black space appears on top of the navigation bar. Has anyone else experienced this problem and how to fix it?

Pushing

3 Answers

You can add a constraint of height 44 to the search bar for iOS 11.

if #available(iOS 11.0, *) {
    searchBar.heightAnchor.constraint(equalToConstant: 44).isActive = true
}

Had the same issue and fixed it by removing the following piece of code from the parent controller during viewWillDisappear

self.navigationController?.setNavigationBarHidden(true, animated: animated)

Related