我知道如何更改UITableViewCell的背景颜色。但是我有一个可能有5-8种不同颜色的数组,我希望表格中的单元格通过该数组并按顺序使用每种背景色,如果单元格的数量大于颜色,则重复该顺序。谢谢!
考虑到您有一个colorArray
,例如:
NSArray *colorArray = @[[UIColor whiteColor], [UIColor blueColor], [UIColor blackColor], [UIColor purpleColor], [UIColor grayColor], [UIColor greenColor]];
您只需在的方法中将设置为cell.backgroundColor
即可。colorArray[indexPath.row%(colorArray.count)]
UITableViewDelegate
tableView:cellForRowAtIndexPath:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句