title: How do I rotate an UIButton in Swift?
body: <p>I used to rotate an image this way:</p>
  
  <pre><code>self.image.transform = CGAffineTransformRotate(self.image.transform, 
                                        CGFloat(M_PI))
  </code></pre>
  
  <p>But this code doesn't work for a button:</p>
  
  <pre><code>let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
  rotateAnimation.fromValue = 0.0
  rotateAnimation.toValue = CGFloat(M_PI)
  </code></pre>
  
  <p>But I don't know how to assign that rotation to the button. How can I do it?</p>