title: iOS: Inverse UIBezierPath (bezierPathWithOvalInRect)
body: <p>I have an jpg Image with a round object in a rect and want to make the envoirement of the round object transparent...</p>
  
  <p><img src="https://i.stack.imgur.com/nA2ZT.jpg" alt="Example"></p>
  
  <p>(Remove red area in this example)</p>
  
  <p>With the help of this <a href="https://stackoverflow.com/questions/8305285/ios-make-part-of-an-uiimage-transparent">iOS make part of an UIImage transparent</a> and "UIBezierPath bezierPathWithOvalInRect" i've got a little success, but this make a path around my object, and I need to invert it, to make the outside and not the inside of the path transparent..</p>
  
  <p>Im not shure where I have to change my code to get the right result..</p>
  
  <p>Here is my code:</p>
  
  <pre><code>//BezierPath
  UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)];  
  
  // Create an image context containing the original UIImage.
  UIGraphicsBeginImageContext(_imgTemp.image.size);
  [_imgTemp.image drawAtPoint:CGPointZero];
  
  // Clip to the bezier path and clear that portion of the image.
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextAddPath(context,bezierPath.CGPath);
  CGContextClip(context);
  CGContextClearRect(context,CGRectMake(0,0,self._imgTemp.image.size.width,self._imgTemp.image.size.height));
  
  // Build a new UIImage from the image context.
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  self._imgTemp.image = newImage;
  </code></pre>
  
  <p>Anybody got the resolving?</p>