UISearchController 的使用

//创建,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;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容