views:

60

answers:

1

I am using this code to rotate a needle (like in a speedometer):

CALayer* layer = someView.layer;
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI];
animation.toValue = [NSNumber numberWithFloat:1.0 * M_PI];
animation.duration = 1.0;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
[layer addAnimation:rotationAnimation forKey:@"transform.rotation.z"];

Now my question is that during the animation i press one button at that time needle is back to move on particular point. So i must have to get last point of layer when i touch button.

How to get last point of layer?

+1  A: 

Your question is very hard to understand, but it seems like you are asking how to determine the state of a progressing animation at the moment a user presses a button. To do this, you can get a CALayer's presentationLayer, and query that for the current value of the property being animated.

The answers to this question show you how to determine the angle of your rotated presentationLayer. You probably want to ignore my needlessly complex answer there.

Brad Larson