title: iOS: Mask a UIImage using UIBezierPath
body: <p>I am trying to mask an image so that I can give it only two rounded corners.  With the code that I have it just adds the mask in white over the image, but doesn't seem to apply it.  What  do I need to do different to mask the image corners?</p>
  
  <pre><code>CAShapeLayer *maskLayer = [CAShapeLayer layer];
  UIBezierPath *roundedPath = [UIBezierPath bezierPathWithRoundedRect:maskLayer.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(16.f, 16.f)];    
  maskLayer.fillColor = [[UIColor whiteColor] CGColor];
  maskLayer.backgroundColor = [[UIColor clearColor] CGColor];
  maskLayer.path = [roundedPath CGPath];
  
  // Add mask
  self.imageView.layer.mask = maskLayer;
  </code></pre>