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 sett
Make a summary in iOS 14+
First to fix push cause extra height:
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.view.setNeedsLayout() // force update layout
navigationController?.view.layoutIfNeeded() // to fix height of the navigation bar
}
Second to fix pop to origin height:
extendedLayoutIncludesOpaqueBars = true
All above code set in the controller with search bar.