I have a custom grouped UITableViewCell, with a couple of UILabels on it. Since the UITableViewCell background color used to be pure white, it matched the UILabels' default background color, so the UILabel box wasn't visible..
After updating to iOS 5.0, I notice that now the default background color for grouped UITableViewCells is a more greyish white (actually #f7f7f7), and as a consequence the UILabels' frame is visible in an ugly way..
So, what is the best way to set the UILabels' background color when it needs to vary between different iOS versions? I know I could use opaque = NO and [UIColor clearColor], but I would prefer to paint the UILabels' background for performance reasons.
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;
}
}
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