title: Stop CALayer shadow from affecting subviews?
body: <p>I have a custom <code>UIControl</code>, and I want it to have a shadow, so I set the relevant properties on its <code>layer</code>.  A shadow appears around the view as desired, but a shadow also appears under the text of a <code>UILabel</code>, which is a subview. How do you stop this? I only want the shadow around the outer superview.</p>
  
  <p><img src="https://i.stack.imgur.com/2pjto.png" alt="enter image description here"></p>
  
  <pre><code>...
  init() {        
      label = UILabel()
      label.translatesAutoresizingMaskIntoConstraints = false
      self.translatesAutoresizingMaskIntoConstraints = false
      addSubview(label)
  
      self.layer.masksToBounds = false
      self.layer.shadowColor = UIColor.blackColor().CGColor
      self.layer.shadowOpacity = 1.0
      self.layer.shadowRadius = 2.0
  
      // Adding these lines trying to explicitly stop shadow on label...
      label.layer.shadowOpacity = 0
      label.layer.shadowColor = nil
      ...
  }
  </code></pre>