title: Shadows not drawing on UIButtons
body: <p>I'm refactoring a Swift 3 project to Swift 4 and I've encountered a situation where buttons that previously had a shadows applied to them no longer draw a shadow.</p>
  
  <p>I'm using this code to draw the shadow:</p>
  
  <pre><code>extension UIButton {  
    func drawShadow() {
      self.layer.drawsAsynchronously = true
      self.layer.masksToBounds = false
      self.layer.shadowColor = UIColor.black.cgColor
      self.layer.shadowOffset = CGSize.zero
      self.layer.shadowRadius = self.layer.cornerRadius
      self.layer.shadowOpacity = 0.5    
    }
  }
  </code></pre>
  
  <p>I call the code to draw the shadow in <code>viewDidLayoutSubviews</code> using this code:</p>
  
  <pre><code>override func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()
      buttonArray = [self.buttonOne, self.buttonTwo, self.buttonThree, self.buttonFour]
      buttonArray.forEach { button in
        button.subviews.filter{$0 is UIImageView}.forEach({ imageView in
          imageView.contentMode = .scaleAspectFit
        })
        button.clipsToBounds = false
        button.drawShadow()
      }
  }
  </code></pre>
  
  <p>I've tried addding the code in <code>viewDidLayoutSubviews</code> in other spots to see if I can get it to draw. I've tried <code>viewDidLoad</code>, <code>viewWillLayoutSubviews</code>, <code>viewDidAppear</code>, etc. I've tried nuking the storyboard and "starting over", by laying out the buttons again, cleaning derived data, nuking the simulator from both terminal and within Xcode.</p>
  
  <p>The buttons are contained within a <code>UIStackView</code>. I've got two horizontal stackviews containing two buttons embedded within a vertical stackview. If anyone's got any suggestions re: what else to try, I welcome your suggestions. Thank you for reading.</p>