Saibot
Saibot

Reputation: 103

Background colors in UITableViewController with UISearchbar

please look at the following screenshot.

different colors tones

It shows a UITableviewController with a UISearchdisplayController in the view header. I have set the background color of the table view to a somehow white color (see the below area). However the area above the UISearchbar does not have the same color (gray). How can I set / change this color? I tried different approaches like:

But till now i have had no success. Can anybody help me? Thanks in advance.

Upvotes: 3

Views: 592

Answers (2)

Saibot
Saibot

Reputation: 103

So i found the issue:

I was using:

self.tableView.tableViewHeader = self.searchDisplayController.searchbar;

Now I am using an aditional view with the searchbar as subview:

UIView *v = [[UIView alloc] initWithFrame:self.searchDisplayController.searchbar.frame];
[v addSubview:self.searchDisplayController.searchbar];
self.tableView.tableHeaderView = v;

Everything works fine now, the gray color is gone and the backgorundColors are equal.

Upvotes: 3

Evgeny S
Evgeny S

Reputation: 82

you can play with

[[UISearchBar appearance] setBarTintColor:[UIColor redColor]];

or

[[UISearchBar appearance] setTintColor:[UIColor greenColor]];

Upvotes: 0

Related Questions