Set background color of UITableViewCell

前端 未结 6 2338
陌清茗
陌清茗 2021-02-15 22:28

I have looked around to find a solution for setting the background color of the accessoryView to the same background color as the cell´s contentView.

    cell.co         


        
6条回答
  •  庸人自扰
    2021-02-15 23:03

    For anyone else who might stumble on this and wants to set their UITableViewCell background to a pattern or texture rather than a solid color, you can do so like this:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        cell.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"pattern.png"]];
    }
    

提交回复
热议问题