Srinivas Ch
Srinivas Ch

Reputation: 1256

Navigation bar Searchbar Space Is not Hiding in Swift 4.2

Navigationbar with SearchBar

enter image description here

HI i have implemented Searchbar in Navigationbar and

Hiding Navigationbar Progamatically but the space is not removing PLease help how can i remove the space of searchbar hiding space

let search = UISearchController(searchResultsController: nil)


    search.searchResultsUpdater = self
    search.obscuresBackgroundDuringPresentation = false
    search.hidesNavigationBarDuringPresentation = false;
    search.searchBar.placeholder = "search..."
    self.definesPresentationContext = true
    self.navigationItem.searchController = search

for Hiding the SearchBar

search.searchBar.isHidden = false

Upvotes: 0

Views: 663

Answers (1)

Arie Pinto
Arie Pinto

Reputation: 1292

Hiding it won't be enough because it is still the navigationItem searchController, so you need to set it to nil

self.navigationItem.searchController = nil

and later restore it if you want, simple as that.

Upvotes: 1

Related Questions