如何在视图动画时识别点击手势

发布于 2024-12-03 13:11:11 字数 254 浏览 1 评论 0原文

只是想知道有没有办法让视图在动画时识别点击手势?我正在研究一个与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

带刺的爱情 2024-12-10 13:11:11

我假设您正在使用 [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.

我是男神闪亮亮 2024-12-10 13:11:11

(Swift 3) 传递 .allowUserInteraction 选项

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

(Swift 3) Pass .allowUserInteraction option

UIView.animate(withDuration: 0.75, delay: 0.0, options: [.allowUserInteraction], animations: {
      // Desired animation(s) 
}, completion: { (finished: Bool) in
        // Completion
})
诠释孤独 2024-12-10 13:11:11

您需要设置两个选项 - UIViewAnimationOptionAllowUserInteractionUIViewAnimationOptionAllowAnimatedContent。首先,您可以在动画期间与视图进行交互;其次,强制在动画的每一帧上重绘视图,而不使用开始帧和结束帧的快照。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文