【发布时间】:2015-02-25 08:45:45
【问题描述】:
当给 UITableView 头部视图添加 UISearchController 时,不可能在 UISearchBar 后面设置背景。
第二张图是拖到底部时的视图。
UITableView 在 Storyboard 中设置,没有任何标题。
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
// Setup appearance
self.searchController.searchBar.barStyle = UIBarStyleBlack;
self.searchController.searchBar.barTintColor = BLUE;
self.searchController.searchBar.tintColor = RED;
// Setup logic
self.searchController.searchBar.scopeButtonTitles = @[ NSLocalizedString(@"students", nil), NSLocalizedString(@"professors", nil), NSLocalizedString(@"rooms", nil) ];
self.searchController.searchBar.delegate = self;
self.searchController.searchResultsUpdater = self;
self.tableView.tableHeaderView = self.searchController.searchBar;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = YES;
我尝试将背景添加到情节提要、超级视图、UITableView 以及手动添加到 UISearchBar。
更多代码here.
【问题讨论】:
标签: ios objective-c uitableview uisearchbar uisearchcontroller