1.导航栏添加搜索框:
let sc=UISearchController(searchResultsController: nil)
sc.searchResultsUpdater = self
self.navigationItem.titleView=sc.searchBar
2.导航栏下面添加搜索框:
let sc=UISearchController(searchResultsController: nil)//放函数外面才有用
sc.searchResultsUpdater = self
tableview.tableHeaderView=sc.searchBar