UITableView cell background color

前端 未结 8 771
别那么骄傲
别那么骄傲 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:45

    You may arrive at the conclusion that 'willDisplayCell' is still not working like I did at first. The reason it didn't work for me initially was because I wasn't using colors properly.

    Don't forget that when using custom colors you need to divide by 255.0f:

    [UIColor colorWithRed:44/255.0f green:50/255.0f blue:65/255.0f alpha:1];

    Something like the following will result to a white cell:

    //DON'T DO [UIColor colorWithRed:44 green:50 blue:65 alpha:1];

    making it look like it's not doing anything when it really is setting the background to white.

提交回复
热议问题