I am using UISearchController to present a search bar inside the header view of a tableview:
...
self.searchController.hidesNavigationBarDuringPresentation =
If you use UINavigationController
and TabBar
you can't use:
self.extendedLayoutIncludesOpaqueBars = true
You would need this solution: https://stackoverflow.com/a/46151063/3369381
In my case, setting the nav bar to self.navigationController.navigationBar.translucent = NO;
fixed the problem. It seems that the search bar presentation layer doesn't take into account the translucence of the nav bar when laying out the search bar.
I realize this isn't a perfect solution, because the translucence of the nav bar can throw off layout elsewhere, but it at least fixes the problem in the case where a non-translucent nav bar is a possibility.
As mentioned in the first post everyone needed a different solution. So here is mine. I had to combine two things mentioned on this page, namely:
Swift 2:
navigationController?.navigationBar.translucent = true
edgesForExtendedLayout = .None