Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White background is showing above UISearchBar for iOS7

My viewController has a UISearchBar set as the header view of a UITableView.

self.tableView.tableHeaderView = self.searchBar;

In iOS7, pulling down beyond the UISearchBar reveals a white space that does not obey the dark color set using self.tableView.backgroundColor.

enter image description here

Is there a way to get rid of the white space?

like image 669
Min Tsai Avatar asked Sep 13 '13 09:09

Min Tsai


2 Answers

I managed to get rid of that color by setting a table view background view.

UIView *backgroundView = [[UIView alloc] initWithFrame:self.tableView.bounds];
backgroundView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundView = backgroundView;
like image 182
Matej Bukovinski Avatar answered Oct 12 '22 07:10

Matej Bukovinski


As developers will likely struggle with the white background in the age of swift:

tableView.backgroundView = UIView()

like image 27
tilo Avatar answered Oct 12 '22 07:10

tilo