I have a button in my app that has a background image. When the button is pressed I want it to rotate 90 degrees. The code below is my IBAction. It works perfectly the first time, but every other time I press the button it doesn't rotate.
@IBAction func addButton(_ sender: UIButton) {
UIView.animate(withDuration: 0.05, animations: ({
sender.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi / 2))
}))
}