Reputation: 7826
I've making practises to use iOS 8 new features - UISearchController to display my tableView and result. But something strange happened. It seems like the searchBar is transparent.
Yes, the searchBar is overlapping with the tableView. I've search a lot in SO, but no help.
My implementation in viewDidLoad
self.myTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_myTableView.delegate = self;
_myTableView.dataSource = self;
[self.view addSubview:_myTableView];
self.mySearchController = [[UISearchController alloc] initWithSearchResultsController:nil];
_mySearchController.searchResultsUpdater = self;
_mySearchController.dimsBackgroundDuringPresentation = NO;
_mySearchController.hidesBottomBarWhenPushed = YES;
_mySearchController.hidesNavigationBarDuringPresentation = YES;
_mySearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal;
[_mySearchController.searchBar sizeToFit];
self.myTableView.tableHeaderView = self.mySearchController.searchBar;
Did I miss something important?
Upvotes: 2
Views: 1051
Reputation: 11
It's because you've set _mySearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal
. According to Apple's documentation:
UISearchBarStyleMinimal - The search bar has no background, and the search field is translucent.
Try deleting that line of code or setting it to UISearchBarStyleDefault
instead.
Upvotes: 1