ipad触摸动画

发布于 2024-11-16 05:46:00 字数 781 浏览 3 评论 0原文

我在使用触摸来制作轮子动画时遇到问题。我花了一些时间为持续时间、旋转时间和动画持续时间输入不同的数字值,以便使用thoughsMove获得平滑的移动,但每次发生触摸时,轮子都会旋转,似乎发生的事情是它跳回到原来的位置。如果有人能对此有所了解,我将非常感激。

CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.delegate = self; 

rotationAnimation.toValue = [NSNumber numberWithFloat: 2  * 1 * 45 ];
rotationAnimation.duration = 2;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1; 


rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];


[animatedImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

Im having trouble animating a wheel using touch. Ive spent some time punching in different numbers values for duration, spin times and animation durations to get a smooth move using on thouchsMove, but every time a touch happens the wheel rotates and what seems to be happening is it jumps back to its original position. If any one can shed some light on this i would very much appreciate it.

CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.delegate = self; 

rotationAnimation.toValue = [NSNumber numberWithFloat: 2  * 1 * 45 ];
rotationAnimation.duration = 2;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1; 


rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];


[animatedImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

z祗昰~ 2024-11-23 05:46:00

对于那些感兴趣的人,下面的代码是获得所需效果所需要的

CGAffineTransform transforms = CGAffineTransformConcat(animatedImage.transform,CGAffineTransformMakeRotation(M_PI/2));
animatedImage.transform = transforms;

for those interested code below is whats needed to get the desired effect

CGAffineTransform transforms = CGAffineTransformConcat(animatedImage.transform,CGAffineTransformMakeRotation(M_PI/2));
animatedImage.transform = transforms;
尤怨 2024-11-23 05:46:00

如果您遇到同样的问题,请按照此示例进行操作,它是正确的。
http://ericmcconkie.com/2010/03/trig-and-objective- c/

If you are having the same problem follow this example, its spot on.
http://ericmcconkie.com/2010/03/trig-and-objective-c/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文