我想在用户按下文本字段输入数据后停止动画并删除提示标签.
文本标签上有重复的动画.创建者:
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?!")}
应根据文件工作.
即使我看到打印在控制台中的字符串,我的标签仍然闪烁.我想问题是动画重复,但不知道如何解决这个问题.
@H_403_19@解决方法//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({.layer.removeAllAnimations()}) self.vIEw.layer.removeAllAnimations() self.vIEw.layoutIfNeeded()}总结
以上是内存溢出为你收集整理的ios – 在swift中删除动画全部内容,希望文章能够帮你解决ios – 在swift中删除动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)