将我们的代码移植到iOS 11中,我正在努力使用UINavigationController中的UISearchbar。
我将SearchController/SearchBar设置为:
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchController.searchBar.scopeButtonTitles = @[@"foo", @"bar"];
self.searchController.searchBar.showsScopeBar = YES;
self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.delegate = self;
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.definesPresentationContext = YES;
if (@available(iOS 11.0, *))
{
self.navigationItem.searchController = self.searchController;
self.navigationItem.hidesSearchBarWhenScrolling = YES;
UISearchBar *searchbar = self.searchController.searchBar;
[searchbar setSomeColors];
}
当使用我们的默认颜色时,事情看起来可能没问题,但搜索栏和ScopeButtons之间的空间可能有点太大: