Skip to content

Instantly share code, notes, and snippets.

@pronebird
Last active August 29, 2015 14:01
Show Gist options
  • Save pronebird/7ca113671b63990b3c22 to your computer and use it in GitHub Desktop.
Save pronebird/7ca113671b63990b3c22 to your computer and use it in GitHub Desktop.
Background color fix for stub view positioned between table view top edge and UISearchBar as header view
//
// Fix background color bug
// This patch can be applied once in viewDidLoad if you use UITableViewController
// http://stackoverflow.com/q/23026531/351305
//
- (void)_fixSearchBarHeaderViewBackgroundColorBug {
// First subview in UITableView is a stub view positioned between table's top edge and table's header view.
UIView* stubView = [self.tableView.subviews firstObject];
// Make sure it's stub view and not anything else
if([NSStringFromClass([stubView class]) isEqualToString:@"UIView"]) {
// Set its alpha to zero to use background color from UITableView
stubView.alpha = 0.0f;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment