//創建,ResultsController可以為nil,即當前VC操作
self.searchController = [[UISearchController alloc] initWithSearchResultsController:[[SearchTableViewController alloc] init]];
self.searchController.searchBar.placeholder =@"在名單里查找";
//searchBar背景顏色
self.searchController.searchBar.barTintColor = RGBA(240, 240, 240, 1);
self.searchController.searchBar.tintColor = [UIColor blackColor];
self.searchController.searchResultsUpdater = self;
//有導航欄的時候,點擊搜索框的時候可以不讓導航欄消失
self.searchController.hidesNavigationBarDuringPresentation = NO;//禁止向上移動
self.searchController.searchBar.frame = CGRectMake(self.searchController.searchBar.frame.origin.x,
self.searchController.searchBar.frame.origin.y,
self.searchController.searchBar.frame.size.width, 44.0);
self.tableView.tableHeaderView = self.searchController.searchBar;