title: Clipping UIView to a circle using CGContextClip
body: <p>I've looked through various similar questions and still can't seem to get my code to work.  I have a UIView with an image drawn to it (<code>[image drawInRect:bounds]</code>), but I'm missing something in my context clipping:</p>
  
  <pre><code>// Get context &amp; bounds, and calculate centre &amp; radius
  CGContextRef ctx=UIGraphicsGetCurrentContext();
  CGRect bounds=[self bounds];
  CGPoint centre;
  centre.x=bounds.origin.x+0.5*bounds.size.width;
  centre.y=bounds.origin.y+0.5*bounds.size.height;
  CGFloat radius=centre.x;
  
  // Draw image
  UIImage *backImage=[UIImage imageNamed:@"backimage.png"];
  [backImage drawInRect:bounds];
  
  // Create clipping path and clip context
  CGMutablePathRef path = CGPathCreateMutable();
  CGPathAddArc(path, NULL, centre.x, centre.y, radius, 0, 2*M_PI, 0);
  CGContextAddPath(ctx, path);
  CGContextClip(ctx);
  </code></pre>
  
  <p>Any ideas of where I went wrong?  Thanks for reading.</p>