【发布时间】:2015-07-26 19:44:45
【问题描述】:
当我点击 UISearchController 中的 UISearchBar 时,它的行为很有趣。
栏的外观分为三种状态。
1:未开发
2:点击
3:点击文字
如您所见,第三个颜色已关闭。它不像其他的那样是黑色的,它的色调是白色的。
这是包含 UISearchController 和 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];
【问题讨论】:
标签: ios cocoa-touch uisearchbar uisearchcontroller