Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 499
Tung Vo Duc Avatar asked Sep 26 '17 23:09

Tung Vo Duc


3 Answers

The problem is that in case of double velocity that your view size is smaller then the navigation controller view size.

So when you scrolling trough the view's frame is changing during changing of content offset and it's doubles velocity as well.
That would explain that behaviour. Please try following to fix the problem.

extendedLayoutIncludesOpaqueBars = true

You should add this line at your UIViewController, UITableViewController or UICollectionViewController

like image 122
BilalReffas Avatar answered Nov 20 '22 08:11

BilalReffas


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
}
like image 40
Shoaib Avatar answered Nov 20 '22 08:11

Shoaib


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)

like image 1
Sharkes Monken Avatar answered Nov 20 '22 08:11

Sharkes Monken