With iOS 11 Apple has redesigned the UISearchBar by making the corners rounder and the height bigger. Adding a UISearchBar to the navigationBar is pretty simple by just setting it as the titleView of the navigationItem using navigationItem.titleView = searchBar
.
However, in iOS 11 it does not seem to work anymore as expected. Have a look at the screens where we compare the same setup using iOS 10 and iOS 11
You can clearly see that the SearchBar increases the size of the NavigationBar but the bar buttons do not get aligned correctly. Also the searchBar does not use the available space on the left anymore.
Putting the searchBar into a wrapper view to get the cancel button on iPad as described here Cancel button is not shown in UISearchBar also does not seem work anymore since the searchBar is then not visible at all.
If anyone has similar issues or already knowns how to fix/improve this I would be very thankful.
This was built using Xcode 9 Beta 4. Maybe future releases will fix this issue.
UPDATE:
Since this does not get "fixed" we now decided to use following solution: We added a new UIBarButtonItem in the NavBar and when the user presses this button we then present a new ViewController where we only put a searchBar into the NavBar which looks good now. Using the selected answer may be the best solution.