我的UISearchController中的UISearchBar在点击它时表现得很有趣。
酒吧外观有三种状态。
如您所见,第三个颜色已关闭。它的颜色是白色,而不是像其他颜色一样黑。
这是包含UISearchController和amp;的设置的代码块。的UISearchBar
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
UINavigationController *navController = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:@"searchVC"];
self.theSearchController = [[UISearchController alloc] initWithSearchResultsController:navController];
self.theSearchController.searchResultsUpdater = self;
self.theSearchController.searchBar.placeholder = @"Search";
self.theSearchController.delegate = self;
self.theSearchController.dimsBackgroundDuringPresentation = YES;
self.theSearchController.searchBar.delegate = self;
self.theSearchController.hidesNavigationBarDuringPresentation = YES;
self.definesPresentationContext = YES;
[self.theSearchController.searchBar sizeToFit];
[self.theSearchController.searchBar setTintColor:[UIColor whiteColor]];
[self.theSearchController.searchBar setBarTintColor:[UIColor blackColor]];
[self.theSearchController.searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"SearchBG.png"] forState:UIControlStateNormal];
[self.theSearchController.searchBar setBarStyle:UIBarStyleBlackTranslucent];
[self.theSearchController.searchBar setSearchBarStyle:UISearchBarStyleMinimal];
[self.tableView setTableHeaderView:self.theSearchController.searchBar];
答案 0 :(得分:0)
我在故事板文件中偶然发现了答案。
UISearchController连接的UINavigationController当然有一个UINavigationBar。当您点击并插入一个字母时,UISearchBar会混合到UINavigationBar中,继承它的颜色。一旦我将UINavigationBar的样式设为Black,UISearchBar继承了它并且它有效。