UITableView cell background color

前端 未结 8 676
别那么骄傲
别那么骄傲 2020-12-08 03:13

how to set different background colors for cells in a UITableView (specifically rainbow color for seven cells)

8条回答
  •  时光说笑
    2020-12-08 03:36

    Pretty sure UITableViewCell is a subclass of UIView, so:

    cell.backgroundColor = [UIColor blueColor];
    

    For awful rainbow colors, here is an example:

    static NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor yellowColor], etc..., nil];
    cell.backgroundColor = [colors objectAtIndex:indexPath.row];
    

提交回复
热议问题