When setting status bar to hidden
override var prefersStatusBarHidden: Bool {
return true
}
and initialize a plain searchController
using
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
It appears normal if unedited, however if you click into the search bar, the navigation title will hide and there is little padding between the search bar and top edge, which is very visually broken.
Solution is appreciated.
https://github.com/DJBen/SearchBarNoTopPadding
This is a bug in iOS 11. To work around it, add these lines to your code:
searchController.hidesNavigationBarDuringPresentation = false
self.definesPresentationContext = true
The alternative is to go on doing this the old way, e.g. make the search controller's search bar your navigation item's titleView
. That does still work fine in iOS 11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With