2

我有一个旋转的图像,但它突然停止。我想添加 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
    }

不知道我错过了什么。任何帮助,将不胜感激!!

4

1 回答 1

3

如果要指定.curveEaseOut,则必须使用带有UIView选项的方法:

UIView.animate(withDuration: 0.5,
               delay: 0,
               options: [ .curveEaseOut ],
               animations: {
                   self.imageGearRight.transform = rotated
               },
               completion: nil)
于 2017-02-27T14:28:52.173 回答