Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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

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

like image 797
Saibot Avatar asked Dec 08 '25 07:12

Saibot


1 Answers

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.

like image 73
Saibot Avatar answered Dec 10 '25 20:12

Saibot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!