iOS - UIPanGestureRecognizer : drag during animation

僤鯓⒐⒋嵵緔 提交于 2019-12-12 02:39:15

问题


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:


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. 


来源:https://stackoverflow.com/questions/13234234/ios-uipangesturerecognizer-drag-during-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!