title: How to get the intersection of two CGPath?
body: <p>I am using <code>CAShapeLayer.path</code> and <code>CALayer.mask</code> to set up image mask, i can achieve "difference set" and "union" effect for <code>CGPath</code> by setting </p>
  
  <pre><code>maskLayer.fillRule = kCAFillRuleEvenOdd/kCAFillRuleZero
  </code></pre>
  
  <p>However, how can i get the intersection of two paths? I cannot achieve it with even-odd rule</p>
  
  <p>Here is an example:
  <img src="https://i.stack.imgur.com/14IqU.png" alt="enter image description here"></p>
  
  <pre><code>let view = UIImageView(frame: CGRectMake(0, 0, 400, 400))
  view.image = UIImage(named: "scene.jpg")
  let maskLayer = CAShapeLayer()
  let maskPath = CGPathCreateMutable()    
  CGPathAddEllipseInRect(maskPath, nil, CGRectOffset(CGRectInset(view.bounds, 50, 50), 50, 0))
  CGPathAddEllipseInRect(maskPath, nil, CGRectOffset(CGRectInset(view.bounds, 50, 50), -50, 0))
  maskLayer.path = maskPath
  maskLayer.fillRule = kCAFillRuleEvenOdd
  maskLayer.path = maskPath
  view.layer.mask = maskLayer
  </code></pre>
  
  <p>how can i get the middle intersection area to be shown?</p>