Reputation: 35953
Ok I can do a vertical gradient on a UITableViewCell doing this on its class:
UIView *backgroundView = [[UIView alloc] init];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor redColor] CGColor],
(id)[[UIColor blueColor] CGColor], nil];
[backgroundView.layer insertSublayer:gradient atIndex:1];
[self setBackgroundView:backgroundView];
but what about a horizontal gradient, from left to right?
Upvotes: 2
Views: 818
Reputation: 15228
Simple documentation checking:
CAGradientLayer
has a startPoint
and endPoint
property. I assume you can use these to position the gradient.
Upvotes: 4