title: Stroke masked CALayer in iOS
body: <p>I'm trying to create a label (or any other view for that matter) with one rounded corner and a stroke/border. I can achieve the former using the following code:</p>
  
  <pre><code>UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds
                                        byRoundingCorners:UIRectCornerBottomRight
                                              cornerRadii:CGSizeMake(16.0f, 16.0f)];
  
  CAShapeLayer *shape = [CAShapeLayer layer];
  shape.frame = self.label.bounds;
  shape.path = maskPath.CGPath;
  
  self.label.layer.mask = shape;
  </code></pre>
  
  <p>Which works great for the rounded corner, but using the following code doesn't apply the stroke the way I want. Instead producing a black (or whatever the <code>backgroundColor</code> of <code>self.label</code> is set to) <strong>square</strong> border.</p>
  
  <pre><code>UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.label.bounds
                                        byRoundingCorners:UIRectCornerBottomRight
                                              cornerRadii:CGSizeMake(16.0f, 16.0f)];
  
  CAShapeLayer *shape = [CAShapeLayer layer];
  shape.frame = self.label.bounds;
  shape.path = maskPath.CGPath;
  
  // Add stroke
  shape.borderWidth = 1.0f;
  shape.borderColor = [UIColor whiteColor].CGColor;
  
  self.label.backgroundColor = [UIColor blackColor];
  self.label.layer.mask = shape;
  </code></pre>
  
  <p>Any suggestions on how I can apply an arbitrary coloured stroke that follows the masked path?</p>