2

I have an image that rotates but it stops abruptly. I'd like to add curveEaseOut to make it stop smoother, but when I add the animations: .curveEaseOut, I get an error.

func rotateRight () {
    let rotation = 90.0
    let transform = imageGearRight.transform
    let rotated = transform.rotated(by: CGFloat(rotation))
    UIView.animate(withDuration: 0.5, animations: .curveEaseOut) {
        self.imageGearRight.transform = rotated
    }
}

I keep getting an error: Type '() -> Void' has no member 'curveEaseOut'

I've also tried this code, but I get an error also:

    UIView.animate(withDuration: 0.5, animations: UIViewAnimationCurve.easeOut) {
        self.imageGearRight.transform = rotated
    }

Not sure what I am missing. Any help would be appreciated!!

Jupiter869
  • 657
  • 2
  • 7
  • 19

1 Answers1

3

If you want to specify .curveEaseOut you have to use a UIView method that takes options:

UIView.animate(withDuration: 0.5,
               delay: 0,
               options: [ .curveEaseOut ],
               animations: {
                   self.imageGearRight.transform = rotated
               },
               completion: nil)
Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200