0

所以情况就是这样,在我的 iPad 屏幕上,我有 768 个小时钟在转动。每个时钟都有一个小时和一个分钟的指针。这些视觉的东西在 UIImageView 里面。我还尝试通过 UIBezierPath/CAShapeLayer 来表示它们,但这对性能没有帮助。当然,当我尝试为所有内容制作动画时,它开始滞后。那么,有没有办法优化呢?动画代码真的很简单

CATransform3D rotationTransform = CATransform3DMakeRotation(M_PI_2, 0, 0, 1);
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
rotationAnimation.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation.duration = 0.5f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;
[_imageViewMinutePointer.layer addAnimation:rotationAnimation forKey:@"transform"];
4

2 回答 2

0

也许通过使用预渲染图像,您可以减轻大量 CPU 资源。1536 时钟不会是大时钟,因此独特图片的数量会很少。

于 2013-08-06T21:10:44.053 回答
0

尝试使用CAReplicatorLayer. 抱歉,我没有示例代码,因为我自己没有使用过它,但我听说它指的是一次动画许多项目的性能。

于 2013-08-06T20:54:12.383 回答