iOS-UIPanGestureRecognizer:动画期间拖动 [英] iOS - UIPanGestureRecognizer : drag during animation

查看:388
本文介绍了iOS-UIPanGestureRecognizer:动画期间拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UIPanGestureRecognizer沿用户绘制的路径移动对象。但是这个对象是动画,我需要在动画过程中与之互动。可能吗?我已经尝试使用 UIViewAnimationOptionAllowUserInteraction 但没有结果。

i use UIPanGestureRecognizer to move an object along the path drawn by the user. But this object is animating and i need to interact with it during animation. Is it possible? I already try to use UIViewAnimationOptionAllowUserInteraction but no results.

推荐答案

是的是可能的。但是我会使用 CABasicAnimation 为对象设置动画,而不是 UIView animationWith ... ,然后添加 UIPanGestureRecognizer 到对象。因此,有一些示例代码:

Yes it is possible. But I would use CABasicAnimation for animating the object and not the UIView animationWith... and then add the UIPanGestureRecognizer to the object. So some example code:

// Configure the animation and add it to the layer.
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
anim.fromValue = ...
anim.duration = ...
[view.layer addAnimation:anim forKey:@"some key"];
// Then add the UIPanGestureRecognizer to that view. 

这篇关于iOS-UIPanGestureRecognizer:动画期间拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆