2015-09-29 53 views
0

我剛剛更新的Xcode 7.0.1來,因此也從雨燕1斯威夫特 斯威夫特2UIViewAnimationOptions錯誤遷移從斯威夫特1至2斯威夫特

我得到了很多的錯誤,當更新已完成,這是我無法修復的問題之一。如果你能爲我解決這個問題真的很好。

錯誤消息說:

無不是與預期型UIViewAnimationOption」

UIView.animateWithDuration(2, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 6, options: nil, animations: ({ 

}), completion: nil) 
+1

可能重複的[請告訴我夫特2.0 animateWithDuration語法?](http://stackoverflow.com /問題/ 30991822 /什麼最迅速-2-0-animatewithduration語法) –

回答

1

使用UIViewAnimationOptions財產對象options:

UIView.animateWithDuration(2, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 6, options: UIViewAnimationOptions.CurveEaseInOut, animations: {() -> Void in 

}, completion: nil) 
0

您可以像使用兼容這個:

UIView.animateWithDuration(0, delay: 0, usingSpringWithDamping: 0, initialSpringVelocity: 0, options: UIViewAnimationOptions.CurveEaseInOut, animations: {() -> Void in 

     }) { (finished: Bool) -> Void in 

    } 

UIView.animateWithDuration(0, delay: 0, usingSpringWithDamping: 0, initialSpringVelocity: 0, options: [UIViewAnimationOptions.CurveEaseInOut, UIViewAnimationOptions.Autoreverse], animations: {() -> Void in 

     }, completion: nil) 
0

在夫特2 UIViewAnimationOption被聲明爲不可選的。因此它不能是nil。相當於沒有選項是通用初始化

... options: UIViewAnimationOption() ... 

或一對空方括號的

... options: [] ...