gpt4 book ai didi

xcode - 标签消失后将其移除

转载 作者:行者123 更新时间:2023-11-30 13:49:41 28 4
gpt4 key购买 nike

我在这里有这段代码,我在其中显示标签,让它消失(直到这里),然后我想删除它。一切正常,直到我想删除它。我需要将其删除,以便我可以再次运行整个过程。这是我的代码:

        view.addSubview(minusLabel)
UIView.animateWithDuration(1.0, delay: 0.0, options: UIViewAnimationOptions.CurveEaseIn, animations: {
self.minusLabel.alpha = 0
}, completion: {
(finished: Bool) -> Void in
self.minusLabel.removeFromSuperview()
}
)

最佳答案

您不需要删除标签来重复动画,而是尝试此代码,并根据您的喜好进行修改:

        func animate() {

UIView.animateWithDuration(1.0, animations: {
self.label.alpha = 1.0
//label is the name of your label which you have defined/created

}, completion: {
(Completed: Bool) -> Void in

UIView.animateWithDuration(1.0, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: {

self.label.alpha = 0
//label is the name of your label which you have defined/created

}, completion: {
(Completed: Bool) -> Void in

self.animate()
})

})

}

每当您想调用此函数时,请使用 animate() 并在其下方添加 label.alpha = 0 (将 label 更改为您的标签名称)。来源:https://www.youtube.com/watch?v=iyg3u3z_fKI

关于xcode - 标签消失后将其移除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34443964/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com