问题
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!!
回答1:
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)
来源:https://stackoverflow.com/questions/42488066/adding-curveeasein-to-swift-animation