简体   繁体   中英

Navigation bar Searchbar Space Is not Hiding in Swift 4.2

带有SearchBar的导航栏

在此处输入图片说明

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM