如何更改搜索栏后面的背景颜色
How to change background colour behind search bar
我试图在 iOS7/8 中自定义我的 UISearchBar
,但我遇到了下一个问题:
我的 searchDisplayController
背后的背景总是浅灰色。这是它的样子:
这是我的一些搜索栏自定义代码:
self.searchDisplayController.searchResultsTableView.backgroundColor = UIColorFromRGB(0x171717);
self.searchDisplayController.searchContentsController.view.backgroundColor = UIColorFromRGB(0x171717);
self.searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.searchDisplayController.searchResultsTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
有什么办法可以解决吗?谢谢
您可以使用以下程序以编程方式更改它:
[searchBar setTintColor:[UIColor darkGrayColor]];
或者通过更改栏色调从 Storyboard 尝试:
尝试更改 xib 中可搜索项的色调
或者在代码中为 [self.searchDisplayController setTintColor:[UIColor whiteColor]];searchDisplayController
原来这个 gray/white 背景是 refreshControl
的一部分。所以你所要做的就是初始化它并设置所需的背景颜色:
self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.backgroundColor = UIColorFromRGB(0x232323);
我试图在 iOS7/8 中自定义我的 UISearchBar
,但我遇到了下一个问题:
我的 searchDisplayController
背后的背景总是浅灰色。这是它的样子:
这是我的一些搜索栏自定义代码:
self.searchDisplayController.searchResultsTableView.backgroundColor = UIColorFromRGB(0x171717);
self.searchDisplayController.searchContentsController.view.backgroundColor = UIColorFromRGB(0x171717);
self.searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.searchDisplayController.searchResultsTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
有什么办法可以解决吗?谢谢
您可以使用以下程序以编程方式更改它:
[searchBar setTintColor:[UIColor darkGrayColor]];
或者通过更改栏色调从 Storyboard 尝试:
尝试更改 xib 中可搜索项的色调
或者在代码中为 [self.searchDisplayController setTintColor:[UIColor whiteColor]];searchDisplayController
原来这个 gray/white 背景是 refreshControl
的一部分。所以你所要做的就是初始化它并设置所需的背景颜色:
self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.backgroundColor = UIColorFromRGB(0x232323);