title: How to mask and add shadow to a UIView
body: <p>I'm making a custom view that i want to mask and to add shadow to it.</p>
  
  <p>the masking:</p>
  
  <pre><code>    let p = UIBezierPath()
      p.moveToPoint(CGPointMake(20, 20))
      p.addLineToPoint(CGPointMake(100, 20))
      p.addLineToPoint(CGPointMake(100, 50))
      p.addLineToPoint(CGPointMake(110, 55))
      p.addLineToPoint(CGPointMake(100, 60))
      p.addLineToPoint(CGPointMake(100, 100))
      p.addLineToPoint(CGPointMake(20, 100))
      p.closePath()
  
      let s = CAShapeLayer()
      s.frame = layer.bounds
      s.path = p.CGPath
      s.fillColor = UIColor.greenColor().CGColor
      layer.mask = s
  </code></pre>
  
  <p>the masking works, now i want to add a shadow.
  but its not working.</p>
  
  <p>i tried to add shadow to the main layer and nothing happens.</p>
  
  <pre><code>    layer.shadowColor = UIColor.yellowColor().CGColor
      layer.shadowRadius = 10
      layer.shadowOpacity = 0.9
      layer.shadowOffset = CGSizeZero
  </code></pre>
  
  <p>i tried to add it to the mask layer and i got the main view masked with a shadow.</p>
  
  <pre><code>    s.shadowColor = UIColor.yellowColor().CGColor
      s.shadowRadius = 10
      s.shadowOpacity = 0.9
      s.shadowOffset = CGSizeZero
  </code></pre>
  
  <p>Any suggestions how to add this yellow shadow to the masked view?</p>
  
  <p>Thanks </p>