ios - how to clip a circle created using CGContextFillEllipseInRect with another circle -


I am drawing a simple circle using the following code in Draw Rect.

CGContextCon = UiGraphicsGetCertChat Contex (); CGContextAddEllipseInRect (cone, CGRactMake (0,0, self.bounds.width, self.boundsskyce.hight)); CGContextSetFillColorWithColor (CO, [UIColor BlueColor] .CGColor); CGContextFillPath (thief);

It pulls a circle properly. Now I want to clip the cycle with another small circle in the middle so that it becomes the hollow cycle and whatever you can see behind the main circle. how can I do this?

Use even-odd rules with CGContextEOClip ()

  CGSize size = rect.size; CGContextRef Reference = UIGraphicsGetCurrentContext (); CGContextTranslateCTM (references, 0, 0); CGContextSaveGState (reference); CGContextAddPath (Reference, ([UIBezierPath bezierPathWithOvalInRect: CGRectMake (0, 0, size.width, size.height)]. CGPath); CGContextAddPath (Reference, ([UIBezierPath bezierPathWithOvalInRect: CGRectMake (size.width / 4, size.height / 4, size.width / 2, size.height / 2)]. CGPath);); CGContextEOClip (reference); // clip CGContextAddPath (context, [UIBezierPath bezierPathWithRect: rect] .CGPath); CGContextSetFillColorWithColor (Reference, [UIColor greenColor] .CGColor); CGContextFillPath (reference); CGContextRestoreGState (reference);  

Comments