Swift UIView.animateWithDuration

Swift UIView.animateWithDuration

在我将 Xcode 更新到 Xcode7.0 后,下面的方法引发了一个非常奇怪的错误:'Double' is not convertible to 'FloatLiteralConvertible'.

UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.5 , initialSpringVelocity: 0.3, options: nil, animations: nil, completion: nil)

有人可以帮助我吗?

该错误似乎与这里的实际问题无关,Swift 2.0 options 现在是 OptionSetType 如果您应该传递一个空的 Array不想指定任何选项。似乎我还必须为 animations(不可为空)指定闭包。

这应该有效:

UIView.animate(withDuration: 0.5, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.3, options: [], animations: {}, completion: nil)