Ios 如何更改搜索栏后面的背景颜色
我试图在iOS7/8中自定义我的Ios 如何更改搜索栏后面的背景颜色,ios,objective-c,uisearchbar,uisearchdisplaycontroller,Ios,Objective C,Uisearchbar,Uisearchdisplaycontroller,我试图在iOS7/8中自定义我的UISearchBar,但遇到了下一个问题: mysearchDisplayController后面的背景始终为浅灰色。这就是它的样子: 这是我的一些搜索栏定制代码: self.searchDisplayController.searchResultsTableView.backgroundColor = UIColorFromRGB(0x171717); self.searchDisplayController.searchContentsController
UISearchBar
,但遇到了下一个问题:
mysearchDisplayController
后面的背景始终为浅灰色。这就是它的样子:
这是我的一些搜索栏定制代码:
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]];
或者通过更改条形图的颜色从情节提要中尝试:
尝试更改xib中可搜索内容的色调
或者在代码中作为
[self.searchDisplayController setTintColor:[UIColor whiteColor]];searchDisplayController
结果显示,此灰/白背景是刷新控件
的一部分。因此,您所要做的就是初始化它并设置所需的背景色:
self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.backgroundColor = UIColorFromRGB(0x232323);
您是否尝试过
self.view.backgroundColor
或self.searchDisplayController.view.backgroundColor
?self.view.backgroundColor
没有帮助,并且searchDisplayController
没有属性view
。它更改了条色。当你向下拖动搜索栏时,他需要更改搜索栏下的空间。