我是一个初学者,一直在通过苹果的Playgrounds和随机的图书教程进行学习。我正在学习一个关于闭包的教程。我在另一个教程中看到过'finish in'这个术语,但我不知道它在通俗易懂的术语中确切地是什么意思。
它完成了什么,正在完成什么,在什么内部完成?还是有一种操作顺序的想法?
这是使用它的函数:
func playSequence(index: Int, highlightTime: Double){
currentPlayer = .Computer
if index == inputs.count{
currentPlayer = .Human
return
}
var button: UIButton = buttonByColor(color: inputs[index])
var originalColor: UIColor? = button.backgroundColor
var highlightColor: UIColor = UIColor.white
UIView.animate(withDuration: 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(index: newIndex, highlightTime: highlightTime)
})
}
finished in
部分,而不是关于UIView animate...
方法的一般性问题。 - rmaddy