Set background color of UITableViewCell

前端 未结 6 1328
执念已碎
执念已碎 2021-02-15 22:47

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:06

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

提交回复
热议问题