I implemented a UITableView with style UITableViewStylePlain. I am using a custom header view with a solid background color, which should be opaque. But the headers are not opaque, leaving the cells visible as they scroll under the header. I want to make the headers opaque, but I don't see how this would done.
When table view is plain, it's visible if at least one of cells in its section is on the screen. So looks like table view sets a background view for header somewhere internally with some alpha. But you could set background view to a custom view and to set background to it then.
You could do this when you create a custom header view in tableView:viewForHeaderInSection:
:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UITableViewHeaderFooterView *header = ...
header.backgroundView = [UIView new];
header.backgroundView.backgroundColor = [UIColor greenColor];
return header;
}
Or if you don't want to create a custom header view, then probably you could set the background in tableView:willDisplayHeaderView:forSection:
fir the default header views.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With