【问题标题】:Swift UIView.animateWithDuration [duplicate]Swift UIView.animateWithDuration [重复]
【发布时间】:2015-07-29 17:07:16
【问题描述】:

在我将 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)

有人可以帮我吗?

【问题讨论】:

    标签: ios swift animation uiview


    【解决方案1】:

    这个错误似乎与这里的真正问题无关,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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      相关资源
      最近更新 更多