我正在制作动画。我想要发生的是在动画完成时移除UIButton,但它在动画完成之前总是消失。我错过了什么吗?
func buttonPressed(sender: UIButton!){
UIView.animateWithDuration(1.0, delay: 0.5, options:[] , animations: {
background.backgroundColor = Yellow
}, completion: {finished in button.removeFromSuperview()})
}
答案 0 :(得分:0)
试试这个:
func buttonPressed(sender: UIButton!){
UIView.animateWithDuration(1.0, delay: 0.5, options:[] , animations: {
background.backgroundColor = Yellow
}, completion: {finished in
if finished {
button.removeFromSuperview()
}
})
}
使用完成块中的finished
标志删除按钮