I'm trying to add a color of a specific gradient to each cell of a table view. So far all I've managed to do, is set the gradient for each of the cells. I've found another post which is close to mine but only sets two colors for alternating rows by determining the number of rows and attributing a certain color depending on whether the row number is pair or not. Here's the link. Here is the code I am using for the gradient of each cell; how do i attribute each color of the gradient to a cell instead?
CAGradientLayer *grad = [CAGradientLayer layer];
grad.frame = cell.bounds;
grad.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:252/255.f green:135/255.f blue:208/255.f alpha:1] CGColor], (id)[[UIColor colorWithRed:253/255.f green:91/255.f blue:105/255.f alpha:1] CGColor], nil];
[cell setBackgroundView:[[UIView alloc] init]];
[cell.backgroundView.layer insertSublayer:grad atIndex:0];
Thanks!