I\'m animating a pendulum which swings from 0 degrees to max 200 degrees and then back again. The problem is that if the pendulum goes over 180 degrees, it returns to 0 by the s
I'm not sure exactly what the issue is, but if you use the animation's auto reverse feature, you can probably simplify this and cause it to rotate (swing) back and forth. This works for me:
CABasicAnimation* rotationAnimation =
[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
[rotationAnimation setToValue:[NSNumber numberWithFloat:DegreesToRadians(200.0)]];
[rotationAnimation setDuration:1.0];
[rotationAnimation setRepeatCount:HUGE_VALF]; // Repeat forever
[rotationAnimation setAutoreverses:YES]; // Return to starting point
[[pendulum layer] addAnimation:rotationAnimation forKey:nil];