I am customizing my UITableView and I figured out how to set the selected color of each cell. In my cellForRowAtIndexPath method, I have the following code:
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor orangeColor]];
[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];
But it is a solid orange. I want to make it more slick looking, and have it be a slight gradient from light orange to darker orange. How can I do this?
You’d use Core Graphics (a.k.a. Quartz) to draw a gradient in your view’s
-drawRect:method:You can limit the area that the gradient fills by creating a path in the current context (ctx) and the clipping to it using
CGContextClip(ctx);.topandbottomare CGPoints that define the beginning and end of the gradient.