cellForRowAtIndexPath에서 각 색상을 계산하면됩니다.
일부 위조 된 코드로 아이디어를 얻을 수 있습니다.
- (UIColor *)colorForRow:(NSInteger)row withTotalRows:(NSInteger)totalRows {
// code to calculate the colors, you can use total rows to insure the end color.
// You will want to calculate the percentage of each color for your gradient.
return color;
}
- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Get your cell first
NSInteger totalRows = [self numberOfRowsInSection:indexPath.section];
cell.contentView.backgroundColor = [self colorForRow:indexPath.row withTotalRows:totalRows];
}
감사합니다. – user3744562