Delete animation in quick

I have a text box in which the user must enter information. And a label that indicates the user a text field (for example, a tooltip).

I want to stop the animation and remove the tooltip shortly as soon as the user clicks a text field to enter data.

The animation on the text label repeats. Created:

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 ) 

After that I created a function to remove annotation

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

Should work in accordance with the documentation.

enter image description here

My shortcut continues to flash, although I see a line printed on the console. I think the problem is that the animation repeats, but has no idea how to solve this problem.

+5
source share
1 answer
 //Just remove the animation from the label. It will Work func remove() { self.hintLabel.layer.removeAllAnimations() self.view.layer.removeAllAnimations() self.view.layoutIfNeeded() } 

Update:

If you want to go for nuclear weapons, you can do this too:

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

All Articles