How to recognize tap gesture while a view is animating

随声附和 提交于 2019-12-03 13:03:42

I'm assuming that you are using the [UIView animateWithDuration: delay: options: animations: completion:]; method of animating.

If so, you need to pass UIViewAnimationOptionAllowUserInteraction as an option to get the animated view to respond to touches while it is animating.

(Swift 3) Pass .allowUserInteraction option

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

You need to set two options - UIViewAnimationOptionAllowUserInteraction and UIViewAnimationOptionAllowAnimatedContent. First lets you interact with views during animation, second forces to redraw views on every frame of animation and not use snapshots of beginning and ending frames.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!