升级我们的应用程序以支持iPhone X.如何将搜索栏添加到表视图的标题并将其放在安全区内?这是我们目前如何建立搜索栏。iphone x:将搜索栏保持在安全区内
let searchController = UISearchController(searchResultsController: nil)
func buildSearchBar() {
self.searchController.searchResultsUpdater = self
self.searchController.hidesNavigationBarDuringPresentation = false
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.searchBar.sizeToFit()
self.tableView.tableHeaderView = searchController.searchBar
self.definesPresentationContext = true
}