Search code examples
iosobjective-cuisearchbaruisearchdisplaycontroller

How to change background colour behind search bar


I trying to customize my UISearchBar in iOS7/8 and I've met next problem: the background behind my searchDisplayController is always light grey. This is how it looks like:

enter image description here

And this is my code of some search bar customization:

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

Is there any way to fix it? Thanks.


Solution

  • As it turned out this gray/white background is part of refreshControl. So all what you have to do is init it and set the needed background color:

    self.refreshControl                 = [[UIRefreshControl alloc] init];
    self.refreshControl.backgroundColor = UIColorFromRGB(0x232323);