21
votes

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
post your code, figuring out something from an image is a shot in the darkmlegg
@mlegg it is just normal pushViewController. This bug happens every where in the app, not just at one place. Besides, in iOS10, iOS9 and iOS8, it is working fine.Tung Vo Duc
can you check your print(view.safeAreaInsets)Vini App
I check it and it was all zeros.Tung Vo Duc
Did you ever fix this? I have the same issueTometoyou

3 Answers

51
votes

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

6
votes

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
}
0
votes

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)