0

I have an UILabel object which is in a continuous animation using a UIView.animate() option. This is working as expected.

I then added a pan gesture (UIPanGestureRecognizer) to this object. However, it does not respond to any pan action while animating. The associated action method is not even invoked based on the debugging that I did. As soon as I disabled its animation, the action method gets triggered when panned and the label handles the gesture correctly. I am wondering if I should suspend its animation when the relevant gesture is initiated. The issue is the action method is not being invoked at all, so I am unsure how to achieve that.

Any suggestion is appreciated. Thank you.

Heelara
  • 861
  • 9
  • 17
  • 1
    you can find this answer here: https://stackoverflow.com/questions/8346100/uibutton-cant-be-touched-while-animated-with-uiview-animatewithduration – Rishabh Aug 02 '17 at 06:15
  • Thanks a lot for your very quick reply! I don't know how my searches failed to find that. I shall add an answer here based on your link. – Heelara Aug 02 '17 at 11:45

1 Answers1

0

Thanks to @Rishabh, I addressed this issue based on the discussion in https://stackoverflow.com/questions/8346100/. I added .allowUserInteraction as options to the animate method as shown below:

UIView.animate(withDuration: 10.0, delay: 0.0, options: [ .allowUserInteraction, .curveLinear ], animations: {
...
})

And now the label is able to animate and still responds to pan!

Heelara
  • 861
  • 9
  • 17