iOS – UIPanGestureRecognizer:在animation中拖动

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

对的,这是可能的。 但我会使用CABasicAnimationanimation的对象,而不是UIView animationWith...然后将UIPanGestureRecognizer添加到对象。 所以一些例子代码:

 // 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.