I'm having some trouble trying to change the background of a UITableView with groups.
_tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tableViewBg.png"]];
This usually works on every other UITableView, but not the one with groups, is there something else I have to do? In IB I have the background color set to a clear color, but that doesn't do much.
You additionally need to disable the background view of _tableView
:
[_tableView setBackgroundView:nil];
_tableView.backgroundColor = [UIColor redColor];
No need to add new view to backgroundView. This is working for me in iOS6
.
why don't you set the tableView.backgroundView? you can alloc an image view withe the specified image and pass it to the background view instead of setting the background color.
What I usually do with grouped UITableViews is set the background color to clear, and the set that pattern image to the parents view.
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tableBG.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
tableView.backgroundView = nil;
tableView.backgroundColor = [UIColor colorWithPatternImage: xxx];
// tableView.backgroundColor = [UIColor redColor]; // is ok
if you set set the backgroundColor as this, when you scroll the tableView, the backgroundColor view will scroll also. so, you can: tableView.backgroundView = nil; self.view.backgroundColor = ...
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