title: How to add a border to this delimited layer?
body: <p>I have an image above which I delimitate a transparent rectangle using layer and mask.
  <strong>I would like this transparent rectangle to be red bordered</strong>. But I could find a way to achieve this :</p>
  
  <p>Here is what I have done :</p>
  
  <p><a href="https://i.stack.imgur.com/Txr0v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Txr0v.png" alt="enter image description here"></a></p>
  
  <p>My ViewController has a darkenedView property.</p>
  
  <pre><code>- (void)loadView {
      UIView *const rootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
      rootView.backgroundColor = [UIColor whiteColor];
      self.view = rootView;
      [self addContentSubviews];
  }
  
  - (void)addContentSubviews {
      UIImageView *const imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"DSC_0823.jpg"]];
      imageView.contentMode = UIViewContentModeScaleAspectFill;
      imageView.frame = self.view.bounds;
      imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
      [self.view addSubview:imageView];
  }
  
  - (void)viewDidLoad {
      [super viewDidLoad];
      [self addDarkenedSubview];
  }
  
  - (void)viewDidLayoutSubviews {
      CGRect const bounds = self.view.bounds;
      darkenedView.center = CGPointMake(CGRectGetMidX(bounds), 0);
  }
  
  - (void)addDarkenedSubview {
      darkenedView = [[UIView alloc] initWithFrame:CGRectMake(10, 30, 400, 1200)];
      darkenedView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.6];
      darkenedView.autoresizingMask = 0;
      [self.view addSubview:darkenedView];
      [self addMaskToDarkenedView];
  }
  
  - (void)addMaskToDarkenedView {
      CGRect bounds = darkenedView.bounds;
      CAShapeLayer *maskLayer = [CAShapeLayer layer];
      maskLayer.frame = bounds;
  
      CGRect const myRect = CGRectMake(CGRectGetMidX(bounds) - 100,
          CGRectGetMidY(bounds) + 100,
          200, 200);
      UIBezierPath *path = [UIBezierPath bezierPathWithRect:myRect];
      [path appendPath:[UIBezierPath bezierPathWithRect:bounds]];
      maskLayer.path = path.CGPath;
      maskLayer.fillRule = kCAFillRuleEvenOdd;
      darkenedView.layer.mask = maskLayer;
  
  }
  </code></pre>
  
  <p>I've tried without success :</p>
  
  <pre><code>maskLayer.strokeColor = [UIColor redColor].CGColor;
  maskLayer.lineWidth = 3.0f;
  </code></pre>