3

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:

  • Adding additional subview
  • Seachbar background color
  • ...

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

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Saibot
  • 103
  • 4
  • Adding a subview to the table view is how I've solved this issue. Update your question with your attempt. – rmaddy Jul 13 '14 at 21:42
  • I used `UIView *view = [UIView new]; view.backgroundColor = [UIColor redcolor]; [self.tableView addSubView:view];` without any success. – Saibot Jul 14 '14 at 11:49

2 Answers2

3

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.

Saibot
  • 103
  • 4
0

you can play with

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

or

[[UISearchBar appearance] setTintColor:[UIColor greenColor]];
Evgeny S
  • 82
  • 4