HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 在swift中删除动画大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个文本字段,用户应该输入信息.以及将用户指向文本字段的标签(如提示).

我想在用户按下文本字段输入数据后停止动画并删除提示标签.

文本标签上有重复的动画.创建者:

override func viewDidLoad() {
    super.viewDidLoad()

    texTinput.addTarget(self,action: #SELEctor(calculatorViewController.removeAnimation(_:)),forControlEvents: UIControlEvents.TouchDown)

     self.hintLabel.alpha = 0.0

    UIView.animateWithDuration(1.5,delay: 0,options: .Repeat,animations: ({
        self.hintLabel.alpha = 1.0
    }),completion: nil           
    )

之后我创建了一个删除注释的函数

func removeAnimation(textField: UITextField) {
    view.layer.removeAllAnimations()
    self.view.layer.removeAllAnimations()
    print("is it working?!")
}

应根据文件工作.

即使我看到打印在控制台中的字符串,我的标签仍然闪烁.我想问题是动画重复,但不知道如何解决这个问题.

解决方法

//Just remove the animation from the label. It will Work

 func remove()

{
    self.hintLabel.layer.removeAllAnimations()
    self.view.layer.removeAllAnimations()
    self.view.layoutIfNeeded()

}

更新:

如果你想要核,你也可以这样做:

func nukeAllAnimations() {
    self.view.subviews.forEach({$0.layer.removeAllAnimations()})
    self.view.layer.removeAllAnimations()
    self.view.layoutIfNeeded()
}

大佬总结

以上是大佬教程为你收集整理的ios – 在swift中删除动画全部内容,希望文章能够帮你解决ios – 在swift中删除动画所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。