导航栏搜索栏 Space 未隐藏在 Swift 4.2 中
Navigation bar Searchbar Space Is not Hiding in Swift 4.2
嗨,我已经在 Navigationbar 和
中实现了 Searchbar
以编程方式隐藏导航栏,但 space 未删除
请帮助我如何删除搜索栏隐藏 space
的 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
用于隐藏搜索栏
search.searchBar.isHidden = false
隐藏它是不够的,因为它仍然是navigationItem
searchController
,所以你需要将它设置为nil
self.navigationItem.searchController = nil
如果需要,稍后可以恢复它,就这么简单。
嗨,我已经在 Navigationbar 和
中实现了 Searchbar以编程方式隐藏导航栏,但 space 未删除 请帮助我如何删除搜索栏隐藏 space
的 spacelet search = UISearchController(searchResultsController: nil)
search.searchResultsUpdater = self
search.obscuresBackgroundDuringPresentation = false
search.hidesNavigationBarDuringPresentation = false;
search.searchBar.placeholder = "search..."
self.definesPresentationContext = true
self.navigationItem.searchController = search
用于隐藏搜索栏
search.searchBar.isHidden = false
隐藏它是不够的,因为它仍然是navigationItem
searchController
,所以你需要将它设置为nil
self.navigationItem.searchController = nil
如果需要,稍后可以恢复它,就这么简单。