Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何更改搜索栏后面的背景颜色_Ios_Objective C_Uisearchbar_Uisearchdisplaycontroller - Fatal编程技术网

Ios 如何更改搜索栏后面的背景颜色

Ios 如何更改搜索栏后面的背景颜色,ios,objective-c,uisearchbar,uisearchdisplaycontroller,Ios,Objective C,Uisearchbar,Uisearchdisplaycontroller,我试图在iOS7/8中自定义我的UISearchBar,但遇到了下一个问题: mysearchDisplayController后面的背景始终为浅灰色。这就是它的样子: 这是我的一些搜索栏定制代码: self.searchDisplayController.searchResultsTableView.backgroundColor = UIColorFromRGB(0x171717); self.searchDisplayController.searchContentsController

我试图在iOS7/8中自定义我的
UISearchBar
,但遇到了下一个问题: my
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]];
或者通过更改条形图的颜色从情节提要中尝试:


尝试更改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
。它更改了条色。当你向下拖动搜索栏时,他需要更改搜索栏下的空间。