iphone - Setting A CGContext Transparent Background -
I'm still struggling with a line drawing with CGContext I actually go to the line to draw , But now I need a back background to be transparent, so the current background shows. Here is my test code:
(zero) direct: (CGRact) rect {CGContextRef context = UIGraphicsGetCurrentContext (); CGContextSetFillColorWithColor (Reference, [UIColor clearColor] .CGColor); CGContextSetAlpha (Reference, 0.0); CGContextFillRect (reference, rect); CGContextSetStrokeColorWithColor (Reference, [UIColor whiteColor] .CGColor); CGContextSetLineWidth (reference, 5.0); CGContextMoveToPoint (Reference, 100.0.0.0); CGContextAddLineToPoint (Reference, 100.0, 100.0); CGContextStrokePath (reference); }
Any ideas?
after Your custom view with the line should include the following: My test has used it as a very basic UIViewController : UIGraphicsGetCurrentContext (
call CGContextClearRect (reference, rect) Edit: OK, got it.
- ( Id) initWithFrame: (CGRect) frame {if (self = [super initWithFrame: frame]) {[self setBackgroundColor: [UIColor clearColor]]} healthy return;} - (zero) direct: (CGRact) shortcut {CGContextRef context = UIGraphicsGetCurrentContext (); CGContextClearRect (reference, rect); CGContextSetStrokeColorWithColor (Reference, [UIColor whiteColor] .CGColor); CGContextSetLineWidth (Reference, 5.0); CGContextMoveToPoi Nt (references, 100.0.0.0); CGContextAddLineToPoint (Reference, 100.0, 100.0); CGContextStrokePath (reference);}
- (zero) viewDidload {{Super Viewedload}; UIImageView * v = [[UIImageView alloc] initWithFrame: self.view.bounds]; [V setback color: [UIColor redColor]]; [Self.view addSubview: v]; Top Viv * T = [[Top Viv Alok] initWithFrame: self.view.bounds]; [Self.view addSubview: t]; [V Release]; [T release]; }
Comments
Post a Comment