我的应用程序中有一个CAKeyframeAnimation。我想要在圆形中移动图像,这就是我使用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"];现在我想知道,如果用户点击显示,动画就会停止,图像就是当前的位置。
我该怎么做呢?
非常感谢
发布于 2015-09-25 22:07:03
使用[imgView.layer removeAnimationForKey:@"moveTheObject"];或[imgView.layer removeAllAnimations];
发布于 2015-09-26 02:37:11
可以,但随后ImageView会移回动画(故事板)之前的位置。我想让它停在动画中的当前位置。
https://stackoverflow.com/questions/32782359
复制相似问题