gpt4 book ai didi

ios - UISearchBar无法显示正确的tintColor

转载 作者:行者123 更新时间:2023-12-01 17:25:35 25 4
gpt4 key购买 nike

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

searchBar.barTintColor = [UIColor colorWithRed:200.0f/255.0f green:21.0f/255.0f blue:26.0f/255.0f alpha:1.0f];

但是如果我将我的UISearchBar引用到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;

我在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];

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

有任何想法吗?

我正在使用iOS7

提前致谢!

最佳答案

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

[[UISearchBar appearance] setBackgroundImage:[UIImage imageNamed:@"red"]];

关于ios - UISearchBar无法显示正确的tintColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23466293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com