title: Removing the shadow on a UIButton while it's being held
body: <p>I have a <code>UIButton</code> which highlighted state involves removing the shadow. What I tried doing is putting a <code>UILongPressGestureRecognizer</code> onto the button:</p>
  
  <pre><code>let gesture = UILongPressGestureRecognizer(target: self, action: #selector(self.removeShadow))
  gesture.numberOfTapsRequired = 1
  gesture.numberOfTouchesRequired = 1
  gesture.delaysTouchesBegan = false
  gesture.delaysTouchesEnded = false
  gesture.minimumPressDuration = 0.01
  self.addGestureRecognizer(gesture)
  </code></pre>
  
  <p>Then in my action, I'm using the states to hide and show the shadow:</p>
  
  <pre><code> @objc func removeShadow(gesture: UILongPressGestureRecognizer) {
      if gesture.state == .recognized {
          UIView.animate(withDuration: 0.1, animations: {
              self.layer.shadowOpacity = 0
          })
      } else if gesture.state == .ended {
          UIView.animate(withDuration: 0.1, animations: {
              self.layer.shadowOpacity = 0.15
          })
      }
  }
  </code></pre>
  
  <p>However, this doesn't seem to trigger anything. The shadow keeps living under the button. Am I missing something here?</p>
  
  <p>Thanks.</p>