title: Masking a CALayer with another CALayer
body: <p>I'm trying to make a donut shape with CALayers. One CALayer will be a large circle, the other one will be a smaller circle positioned in its center, masking it. </p>
  
  <p>The large circle displays fine, but whenever I call <code>circle.mask = circleMask;</code> then the view appears empty. </p>
  
  <p>Here's my code:</p>
  
  <p><strong>AriDonut.h</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface AriDonut : UIView
  -(id)initWithRadius:(float)radius;
  @end
  </code></pre>
  
  <p><strong>AriDonut.m</strong></p>
  
  <pre><code>#import "AriDonut.h"
  #import &lt;QuartzCore/QuartzCore.h&gt;
  
  @implementation AriDonut
  
  -(id)initWithRadius:(float)radius{
      self = [super initWithFrame:CGRectMake(0, 0, radius, radius)];
      if(self){
  
          //LARGE CIRCLE
          CALayer *circle = [CALayer layer];
          circle.bounds = CGRectMake(0, 0, radius, radius);
          circle.backgroundColor = [UIColor redColor].CGColor;
          circle.cornerRadius = radius/2;
          circle.position = CGPointMake(radius/2, radius/2);
  
          //SMALL CIRLCE
          CALayer *circleMask = [CALayer layer];
          circleMask.bounds = CGRectMake(0, 0, 10, 10);
          circleMask.cornerRadius = radius/2;
          circleMask.position = circle.position;
  
          //circle.mask = circleMask;
  
          [self.layer addSublayer:circle];
  
      }
  
      return self;
  }
  </code></pre>
  
  <p>I've tried setting the large circle's superlayer nil like this:</p>
  
  <pre><code>CALayer *theSuper = circle.superlayer;
  theSuper = nil;
  </code></pre>
  
  <p>But it didin't make a difference. </p>
  
  <p>I also tried setting Circle's <code>masksToBounds</code> property to YES and NO, but it didn't make a difference.</p>
  
  <p>Any thoughts?</p>