How to recognize a gesture of clicking when an animation is animated

Just wondering if there is a way to recognize the tap gesture while it is being animated? I am working on a view in which the cashapelayer line is tied. When the user clicks on the view (gesture gestures), the line follows accordingly until the user stops panning. At this stage, an animation is performed that returns the view back to its original position, as well as the cable layer. Now my only real problem is that while the view and anchor enliven the view, they don’t respond to click gestures ...

Does anyone know any tricks? I hope my explanation was clear and in advance!

(if the concept of a bound view is unclear, there is a free application called discovr application that will give an example).

+6
source share
3 answers

I assume that you are using the animation method [UIView animateWithDuration: delay: options: animations: completion:]; .

If so, you need to pass UIViewAnimationOptionAllowUserInteraction as an option so that the animated view responds to touches during the animation.

+16
source

You need to set two options - UIViewAnimationOptionAllowUserInteraction and UIViewAnimationOptionAllowAnimatedContent . First, you can interact with the views during the animation, and secondly, redraw the views on each frame of the animation and not use snapshots of the start and end frames.

+2
source

(Swift 3) Pass .allowUserInteraction option

 UIView.animate(withDuration: 0.75, delay: 0.0, options: [.allowUserInteraction], animations: { // Desired animation(s) }, completion: { (finished: Bool) in // Completion }) 
+1
source

Source: https://habr.com/ru/post/896807/


All Articles