我有一个旋转的图像,但它突然停止了。我想添加 curveEaseOut 以使其停止更平滑,但是当我添加动画:.curveEaseOut 时,出现错误。
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
}
}
我不断收到错误: 类型“() -> Void”没有成员“curveEaseOut”
我也尝试过这段代码,但也收到错误:
UIView.animate(withDuration: 0.5, animations: UIViewAnimationCurve.easeOut) {
self.imageGearRight.transform = rotated
}
不知道我错过了什么。任何帮助将不胜感激!!
最佳答案
如果您想指定.curveEaseOut
,您必须使用带有选项的UIView
方法:
UIView.animate(withDuration: 0.5,
delay: 0,
options: [ .curveEaseOut ],
animations: {
self.imageGearRight.transform = rotated
},
completion: nil)
关于ios - 将 curveEaseIn 添加到 Swift 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42488066/