Ios XCode-如何停止CAKeyframeAnimation
我的应用程序中有一个关键帧动画。我想在圆环中移动一个图像,这就是为什么我要使用CAKeyframeAnimation。这是我目前的代码:Ios XCode-如何停止CAKeyframeAnimation,ios,xcode,animation,Ios,Xcode,Animation,我的应用程序中有一个关键帧动画。我想在圆环中移动一个图像,这就是为什么我要使用CAKeyframeAnimation。这是我目前的代码: CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = k
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]代码>是,但随后图像视图移回动画(情节提要)之前的位置。我希望它停止在动画中的当前位置