Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIImage基于用户与地图的交互在MapView上启动和停止动画_Ios_Animation_Uiimageview_Mkmapview - Fatal编程技术网

Ios UIImage基于用户与地图的交互在MapView上启动和停止动画

Ios UIImage基于用户与地图的交互在MapView上启动和停止动画,ios,animation,uiimageview,mkmapview,Ios,Animation,Uiimageview,Mkmapview,我有一个UIImageView,它当前正在从屏幕上的一个点到另一个点进行动画制作,然后无限次地返回。以下是该动画的代码: CGPoint startPoint = (CGPoint){self.view.frame.size.width/2, self.view.frame.size.height/2-(PIN_HEIGHT/2)-35}; CGPoint endPoint = (CGPoint){self.view.frame.size.width/2, self.view.fram

我有一个
UIImageView
,它当前正在从屏幕上的一个点到另一个点进行动画制作,然后无限次地返回。以下是该动画的代码:

CGPoint startPoint = (CGPoint){self.view.frame.size.width/2,     self.view.frame.size.height/2-(PIN_HEIGHT/2)-35};
CGPoint endPoint = (CGPoint){self.view.frame.size.width/2,  self.view.frame.size.height/2-(PIN_HEIGHT/2)-20};

CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);

CAKeyframeAnimation *animation = [CAKeyframeAnimation  animationWithKeyPath:@"position"];

animation.duration = 1.f;
animation.path = thePath;
animation.autoreverses = YES;
animation.repeatCount = INFINITY;

[userPin.layer addAnimation:animation forKey:@"position"];
现在,
UIImageView
的动画正在
MKMapView
上进行动画制作。我的问题来了:我希望动画在默认情况下以及用户与地图交互时发生。但是,当用户触摸地图并停止与它交互时,我希望动画停止,但一旦用户再次移动地图,动画就可以重新开始

有什么办法可以做到这一点吗?非常感谢