Try using cell.bounds
instead of cell.frame
, since the gradient frame should be relative to the cell. NSLog
the gradient frame as shown below, and verify that the origin is {0,0}.
NSLog( @"%@", NSStringFromCGRect( gradient.frame ) );
Also, be careful, each time you pull a cell out of the reuse queue, it will still be configured as when it went into the reuse queue. So you need to make sure that you don't add a gradient to a cell that already has a gradient, or you could run into memory problems.
I think this is what you wanted for gradframe
CGRect gradframe = CGRectMake(0, 0, self.view.frame.size.width, cell.frame.size.height);