CoreAnimation是一件非常简单的事情,但是:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:30];
MyImageView.frame = CGRectOffset(MyImageView.frame, 100, 0);
[UIView commitAnimations];我想将ImageView缓慢地移动100像素。因此,所有的定位值都是双精度的,我希望values系统能够以亚像素精度定位项目。但是当我看这个动画的时候,我看到的是ImageView像素级的“跳跃”,而不是平滑的移动。有什么想法来实现真正的子像素定位吗?我也试着用计时器设置位置,并重新计算帧值,但效果相同。
更新:在我的应用程序的其他部分,我使用加速度计来更新ImageView的位置,并基本计算图形的位置和大小,然后执行以下操作:
MyImageView.frame = newCGRect; 我从加速度计获得了大约60次更新/秒,并添加了来自Apple的加速度计示例的LowPass-Filter。
这里的定位是完美的?!?!
为什么在CoreAnimation中不会发生这种情况?
谢谢你的帮助。
发布于 2011-05-03 02:29:38
尝试使用CGAffineTransformTranslate(MyImageView.transform,100,0)代替CGRectOffset。
参考地址:http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html
发布于 2012-09-28 15:18:04
如果你在QuartzCore框架中使用CABasicAnimation,你可以使用"CAMediaTimingFunction“来平滑你的动画。内置的替代方法对我来说很有效,但据我所知,你也可以定义自己的计时函数。
CABasicAnimation *starShineAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
starShineAnimation.removedOnCompletion = NO;
starShineAnimation.fillMode = kCAFillModeForwards;
starShineAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
....https://stackoverflow.com/questions/4431451
复制相似问题