I've seen various posts on background color for a UITableView for ios 4.2 but I just cannot seem to change the background color.
UIView *bgView = [[[UIView alloc] init] autorelease];
bgView.backgroundColor = [UIColor blackColor];
bgView.opaque = YES;
self.myTableView.backgroundView = bgView;
I've placed this code in a viewDidLoad but it won't change colors. My UITableView is an IBOutlet inside a UIViewController with a UITableViewDelegate & UITableViewDataSource so I'm thinking at the viewDidLoad the UITableView is already rendered and I cannot change its background color.
EDIT * - the UITableView is grouped
For changing the background color of the table view cell, you should change the contentView. backgroundColor property of the cell. Now run the project to see the effect.
Try setting the background view of the table view to nil and also set the background colour of the table view
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.myTableView.backgroundView = nil;
self.myTableView.backgroundColor = [UIColor blackColor];
}
Simply changee the backgroundColor property of both tableView and tableView's backgroundView.
- (void)viewDidLoad {
[super viewDidLoad];
id desiredColor = [UIColor clearColor];
self.tableView.backgroundColor = desiredColor;
self.tableView.backgroundView.backgroundColor = desiredColor;
}
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