Different cell bg color depending on iOS version (4.0 to 5.0)
In the delegate method tableView:willDisplayCell:
, the UITableViewCell
will have the background colour set to white or, in iOS 5, greyish.
You can change all your the backgroundColor
of all your subviews.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
for (UIView* view in cell.contentView.subviews) {
view.backgroundColor = cell.backgroundColor;
}
}
Nothing wrong with gcamp's answer, but if you'd prefer to keep the background white on both iOS4 and iOS5, then just do this:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell setBackgroundColor:[UIColor whiteColor]];
}
I saw that problem in my custom UITableViewCell in a grouped TableView I just set the label background color to clear and that fixed it for me and works in iOS4 and iOS5. I set this in the custom cell code where the UILabel gets created as below:
[nameLabel setBackgroundColor:[UIColor clearColor]];
After that problem gone.