繁体   English   中英

动画和从SuperView中删除UIButton

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM