Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 删除swift中的动画_Ios_Swift_Animation_Swift2_Uiviewanimation - Fatal编程技术网

Ios 删除swift中的动画

Ios 删除swift中的动画,ios,swift,animation,swift2,uiviewanimation,Ios,Swift,Animation,Swift2,Uiviewanimation,我有一个文本字段,用户应该在其中输入信息。以及一个将用户指向文本字段的标签(如提示) 我想在用户按下文本字段输入数据后停止动画并删除提示标签 文本标签上有重复的动画。由以下人员创建: override func viewDidLoad() { super.viewDidLoad() textInput.addTarget(self, action: #selector(CalculatorViewController.removeAnimation(_:)), forContr

我有一个文本字段,用户应该在其中输入信息。以及一个将用户指向文本字段的标签(如提示)

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

文本标签上有重复的动画。由以下人员创建:

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()
}