[英]XCode - how to stop a CAKeyframeAnimation
我的應用程序中有一個CAKeyframeAnimation。 我想在cirlce中移動圖像,這就是為什么我使用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 removeAllAnimations];
是的,但是ImageView返回到動畫之前的位置(storyboard)。 我希望它停止在動畫的當前位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.