![](/img/trans.png)
[英]Removing a view from it's superview after animation repositions other views
[英]Animation and Removing UIButton from SuperView
我正在制作动画。 我想发生的是在动画完成时将UIButton删除,但是在动画完成之前它总是消失。 我想念什么吗?
func buttonPressed(sender: UIButton!){
UIView.animateWithDuration(1.0, delay: 0.5, options:[] , animations: {
background.backgroundColor = Yellow
}, completion: {finished in button.removeFromSuperview()})
}
尝试这个:
func buttonPressed(sender: UIButton!){
UIView.animateWithDuration(1.0, delay: 0.5, options:[] , animations: {
background.backgroundColor = Yellow
}, completion: {finished in
if finished {
button.removeFromSuperview()
}
})
}
使用finished
标志在完成块中删除您的按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.