1

I'm trying to add a search bar inside the navigation bar, here's my code:

class ViewController: UIViewController {
    var searchController : UISearchController!

    override func viewDidLoad() {
        super.viewDidLoad()
        searchController = UISearchController(searchResultsController:nil)
        searchController.hidesNavigationBarDuringPresentation = false

        navigationItem.searchController = searchController

        definesPresentationContext = true
    }
}

It seems to work fine, but I can't find a way to reduce the navigation bar height. I don't need the extra space at the top.

enter image description here enter image description here



Here's what I'm trying to achieve (default Messages search bar):

enter image description here

guidev
  • 2,695
  • 2
  • 23
  • 44

0 Answers0