我已经在导航栏中实现了搜索栏
以编程方式隐藏导航栏但空间不移除PLease帮助我如何删除搜索栏隐藏空间的空间
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
然后如果你想要恢复它,就像那样简单。