我想按下按钮时将图像旋转190度.这有效,但当我再次按下按钮时,动画需要从最后结束的地方开始,而不是从0开始.所以每次按下按钮,动画需要转动190度.
因为我的fromValue设置为0,所以每次都从0开始.
有人知道我如何使我的图像结束的fromValue开始.我的代码在这里.
- (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"];
}
Run Code Online (Sandbox Code Playgroud)