iOS - UIPanGestureRecognizer : drag during animati

2019-08-19 03:11发布

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.

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-19 03:58

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. 
查看更多
登录 后发表回答