title: Make area around masked region transparent with CALayers?
body: <p>I'm trying to crop an image to an irregular shape, but I need to make the area that was removed transparent.</p>
  
  <p>Inside subclass of UIView      </p>
  
  <pre><code>   CALayer *myLayer = [CALayer layer];
     CAShapeLayer *mask = [CAShapeLayer layer];    
      myLayer.frame = self.bounds;
      myLayer.contents =  (id)[self.picture CGImage];
      mask.path = path;
      myLayer.mask = mask;
      [self.layer addSublayer:myLayer];
  </code></pre>
  
  <p>This will crop the image appropriately, but the background color of the view is white and therefore still visible. I've tried making the other layers transparent, but it has not worked.</p>
  
  <p>(self and subview both refer to same view)</p>
  
  <pre><code>[self layer].backgroundColor = [UIColor clearColor].CGColor //no change
  [self layer].opacity = 0; //makes entire view transparent
  subView.backgroundColor = [UIColor clearColor]; // entire view becomes transparent
  </code></pre>
  
  <p>Is it possible to create the effect I'm trying to achieve?</p>