【发布时间】:2012-01-27 14:38:50
【问题描述】:
我想在按下按钮时将图像旋转 190 度。那行得通,但是当我再次按下按钮时,动画需要从上次结束的地方开始,而不是从 0 开始。所以每次我按下按钮时,动画都需要旋转 190 度。
每次都从 0 开始,因为我的 fromValue 设置为 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"];
}
【问题讨论】:
标签: xcode image rotation cabasicanimation