Set background color of UITableViewCell

前端 未结 6 2330
陌清茗
陌清茗 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:07

    For all lines with the same color

    cell.backgroundColor = [UIColor colorWithRed:6.0/255.0 green:122.0/255.0 blue:145.0/255.0 alpha:1.0f];
    

    For 2 colors

    cell.backgroundColor = [UIColor colorWithRed:6.0/255.0 green:122.0/255.0 blue:145.0/255.0 alpha:1.0f];
    
        if ((cell.backgroundColor = (indexPath.row % 2 == 0 ? [UIColor colorWithRed:6.0/255.0 green:122.0/255.0 blue:145.0/255.0 alpha:1.0f] : [UIColor colorWithRed:2.0/255.0 green:68.0/255.0 blue:80.0/255.0 alpha:1.0f]))){
            cell.textLabel.textColor = [UIColor whiteColor];
    
    }
    

提交回复
热议问题