Different cell bg color depending on iOS version (4.0 to 5.0)

后端 未结 6 1842
深忆病人
深忆病人 2021-01-02 07:51

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

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-02 08:38

    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;
        }
    }
    

提交回复
热议问题