如何使用 Swift(在子类 UIView 中)锁定和解锁 UIView 动画完成 block 中的关键代码部分?
func MoveCard(sourcePile: Pile, destPile: Pile) {
// Temporarily disable user interaction
disableUserInteraction()
// Move card from source pile to destination pile
UIView.animateWithDuration(0.1) {
() -> Void in
// Move card center
self.center = destPile.center
// CRITICAL SECTION OF CODE
// Add card to destination pile array
destPile.cards.append(sourcePile.cards.last!)
// Remove card from source pile array
sourcePile.cards.removeLast()
// Reenable user interaction
enableUserInteraction()
}
}
最佳答案
试试这个:
UIView.animateWithDuration(0.1, animations: {
// your animation code
}, completion: { (complete: Bool) in
// your completion code
})
关于swift - 锁定/解锁 UIView 动画完成 block 中代码的关键部分 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31615481/