2017-02-27 76 views
0

我有一个旋转但突然停止的图像。我想添加curveEaseOut使其停止平滑,但是当我添加动画:.curveEaseOut时,出现错误。将curveEaseIn添加到Swift动画

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 
    } 
} 

我不断收到一个错误: 类型 '() - >无效' 没有成员 'curveEaseOut'

我也试过这个代码,但我得到一个错误也:

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

不知道我缺少什么。任何帮助,将不胜感激!!

回答

0

如果要指定.curveEaseOut你必须使用一个UIView方法,该方法的选择:

UIView.animate(withDuration: 0.5, 
       delay: 0, 
       options: [ .curveEaseOut ], 
       animations: { 
        self.imageGearRight.transform = rotated 
       }, 
       completion: nil) 
+0

非常感谢您!你一直在帮助很大! – Jupiter869