Set background color of UITableViewCell

前端 未结 6 1303
执念已碎
执念已碎 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 22:52

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

提交回复
热议问题