Reputation:
Why is this Swift function requiring more context now? This shows up on the line with .CurveLinear
func playSequence(index:Int,highlightTime:Double){
currentPlayer = .Computer
if index == inputs.count{
currentPlayer = .Human
return
}
var button:UIButton = buttonByColor(inputs[index])
var originalColor:UIColor? = button.backgroundColor
var highlightColor:UIColor = UIColor.whiteColor()
UIView.animateWithDuration(highlightTime,delay: 0.0,options: .CurveLinear & .AllowUserInteraction & .BeginFromCurrentState,
animations:{
button.backgroundColor = highlightColor
}, completion: {
finished in button.backgroundColor = originalColor
var newIndex:Int=index+1
self.playSequence(newIndex, highlightTime: highlightTime)
})
}
Upvotes: 1
Views: 423
Reputation: 19954
Swift 2 syntax for multiple options requires an option set in square brackets. In your animateWithDuration you need to create an option set:
UIView.animateWithDuration(highlightTime,delay: 0.0,options:[.CurveLinear, .AllowUserInteraction, .BeginFromCurrentState],
animations:{
button.backgroundColor = highlightColor
}, completion: {
finished in button.backgroundColor = originalColor
var newIndex:Int=index+1
self.playSequence(newIndex, highlightTime: highlightTime)
})
You can also define a set explicitly like this:
let mySet : UIAnimationOptions = [.CurveLinear, .AllowUserInteraction, .BeginFromCurrentState]
Upvotes: 2