UISearchBar无法显示正确的tintColor

oma*_*rc7 1 cocoa-touch uisearchbar uisearchdisplaycontroller ios

如果我添加UISearchBar而不将其引用到UISearchDisplayController,则我的tintColor将正确显示。

UISearchBar具有正确的tintColor

searchBar.barTintColor = [UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f];
Run Code Online (Sandbox Code Playgroud)

但是,如果我将我的UISearchBar引用到UISearchDisplayController,则颜色似乎有所不同...

UISearchBar引用了带有错误的tintColor的UISearchDisplayController

searchBar = [[UISearchBar alloc] init];
[searchBar setBarTintColor:[UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f]];
searchBar.delegate = self;
searchBar.searchBarStyle = UISearchBarStyleProminent;
searchBar.placeholder = @"Buscar restaurantes o platillos";
searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;

searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
    searchController.delegate = self;

self.tableView.tableHeaderView = searchBar;
Run Code Online (Sandbox Code Playgroud)

我在AppDelegate上的tintColor设置是

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[[UIToolbar appearance] setBarTintColor:[UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f]];
self.window.tintColor = [UIColor whiteColor];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.backgroundColor = [UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f];
Run Code Online (Sandbox Code Playgroud)

除此之外,当我的UISearchBar被引用到我的UISearchDisplayController时,我点击搜索字段...在过渡时,状态栏的背景为白色。

在UISearchDisplayController上转换UISearchBar

有任何想法吗?

我正在使用iOS7

提前致谢!

Ban*_*tal 5

您可以在搜索器中设置图像。它将适用于搜索栏。

[[UISearchBar appearance] setBackgroundImage:[UIImage imageNamed:@"red"]];
Run Code Online (Sandbox Code Playgroud)