Tuesday, 6 August 2013

Performance of 1536 rotating CABasicAnimations

Performance of 1536 rotating CABasicAnimations

So here is the case, on my iPad screen I have 768 little clocks turning.
Each clock has an hour and a minute pointer. These visual things are
inside an UIImageView. I also tried to represent them via a
UIBezierPath/CAShapeLayer but this didn't help performance. Of course when
I try to animate all that it starts to lag. So, is there a way to optimize
this? The animation code is really simple
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"];

No comments:

Post a Comment