views:

55

answers:

0

i am trying to rotate an image of a pencil in uiimageview when user swipes in a particular direction on the imageview by using the following code

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

CABasicAnimation *fullRotation;
fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 2;
//fullRotation.repeatCount = 1e100f;
fullRotation.repeatCount = 2;

[img.layer addAnimation:fullRotation forKey:@"360"];}

i can make the image rotate only till a certain point by changing the fullRotation.toValue but after the rotation the image will return to its original straight position on the UIImageview while i want the image to remain at the value i have defined?? do i need to maybe give some axis to UIImageview equal to above value of fullRotation after rotation has finished??