Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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 XCode-如何停止CAKeyframeAnimation_Ios_Xcode_Animation - Fatal编程技术网

Ios XCode-如何停止CAKeyframeAnimation

Ios XCode-如何停止CAKeyframeAnimation,ios,xcode,animation,Ios,Xcode,Animation,我的应用程序中有一个关键帧动画。我想在圆环中移动一个图像,这就是为什么我要使用CAKeyframeAnimation。这是我目前的代码: CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = k

我的应用程序中有一个关键帧动画。我想在圆环中移动一个图像,这就是为什么我要使用CAKeyframeAnimation。这是我目前的代码:

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation        animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;    
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
pathAnimation.duration = 5.0;
pathAnimation.repeatCount = 0;

CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, 10, 10);

CGRect rectangle = CGRectMake(69,211,239,243);

CGPathAddEllipseInRect(curvedPath, NULL, rectangle);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);

[imgView.layer addAnimation:pathAnimation forKey:@"moveTheObject"];
现在我想知道,如果用户点击显示器,动画停止,图像是当前位置

我该怎么做


非常感谢

使用
[imgView.layer removeAnimationForKey:@“moveTheObject”]
[imgView.layer RemoveAllianimations]

是,但随后图像视图移回动画(情节提要)之前的位置。我希望它停止在动画中的当前位置