Reputation: 11493
I'm replacing the background view of a UITableViewCell
with my own custom subclass of UIView
, in which I override the drawRect
method with my own, which creates a multi-colored and changing background.
The problem is that when the TableViewCell
is selected, the graphics under are completely hidden and it looks odd. I need to create a custom selectedBackgroundView
in order to fix this. The problem is that that view needs to create a blue gradient tint over the graphics already there, and I don't know how to draw a CGRect
or something similar that is partially transparent.
Upvotes: 0
Views: 690
Reputation: 13600
// Write this In your - (void)drawRect:(CGRect)rect
// To draw semi transparent Square
// Create Current Context To Draw
CGContextRef context = UIGraphicsGetCurrentContext();
UIBezierPath *square = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
// following method will fill red color with alpha 0.4 last one in parameter list
// first 3 are Red, Green and Blue Respectively.
CGContextSetRGBFillColor(context, 1, 0, 0, 0.4);
[square fill];
[square stroke];
Upvotes: 2