I want to turn an image 190 degrees when pressing a button. That works but when i press the button again the animation needs to start where it last ended, instead of starting from 0. So everytime i press the button, the animation need to turn a 190 degrees.
It is starting at 0 everytime becouse my fromValue is set to 0.
Does someone know how i can make the fromValue start where my image ends. My code is below here.
- (IBAction)buttonPressed
{
CABasicAnimation *imageRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
imageRotation.fromValue = [NSNumber numberWithFloat:0];
imageRotation.toValue = [NSNumber numberWithFloat:((190*M_PI)/ -180)];
imageRotation.duration = 1.5;
imageRotation.repeatCount = 1;
imageRotation.removedOnCompletion = NO;
imageRotation.autoreverses=NO;
imageRotation.fillMode = kCAFillModeForwards;
[image.layer addAnimation:imageRotation forKey:@"imageRotation"];
}
Thanks for your answer, but here is how i did it. Hope people can use this 😀
My .h file looks like this:
My .m file looks like this: