如何在视图动画时识别点击手势
只是想知道有没有办法让视图在动画时识别点击手势?我正在研究一个与 Cashapelayer 线相连的视图。当用户平移视图(平移手势)时,线条会相应地跟随,直到用户停止平移。此时会执行一个动画,将视图带回到其原始位置,并且系绳层也返回。现在我唯一真正的问题是,当视图和系绳动画时,视图不会响应点击手势……
有人知道一些技巧吗?我希望我的解释是可以理解的,并提前致谢!
(如果束缚视图概念不清楚,有一个名为discovr apps 的免费应用程序将给出一个示例)。
Just wondering is there way to have a view recognize tap gestures while it is being animated? I am working on a view that has a cashapelayer line tethered to it. When the user pans the view (pan gesture) the line follows accordingly until the user stops panning. At this point an animation is executed that brings the view back to its original position and the tether layer back as well. Now my only real problem is that while the view and the tether are animating the view doesnt respond to tap gestures…
Anyone know some tricks? I hope my explanation was understandable and thanks in advance!
(if the tethered view concept is not clear there is a free app called discovr apps which will give an example).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您正在使用
[UIView animateWithDuration:delay:options:animations:completion:];
动画方法。如果是这样,您需要传递 UIViewAnimationOptionAllowUserInteraction 作为选项,以使动画视图在动画时响应触摸。
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) 传递 .allowUserInteraction 选项
(Swift 3) Pass .allowUserInteraction option
您需要设置两个选项 -
UIViewAnimationOptionAllowUserInteraction
和UIViewAnimationOptionAllowAnimatedContent
。首先,您可以在动画期间与视图进行交互;其次,强制在动画的每一帧上重绘视图,而不使用开始帧和结束帧的快照。You need to set two options -
UIViewAnimationOptionAllowUserInteraction
andUIViewAnimationOptionAllowAnimatedContent
. 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.