我想做出一些相对简单的事情,使用户触摸按钮时旋转90度,大部分我迄今为止所做的工作是第一次,但此后该图像赢得'移动。我希望它保持新的位置,然后从新位置旋转90度,我有 [UIView setAnimationBeginsFromCurrentState:YES];旋转UIImageView与核心动画
,但似乎并没有工作
我加一个NSTimer“重置”原始图像的方向,使车轮弹回原来的位置,然后当用户触摸它再次旋转。 ...然而这并不是我想要的。
有没有办法使图像保持旋转90度,因此用户四次触摸会使图像回到其原始位置。谢谢你的帮助!!
这里是示例代码
-(IBAction) rotatewheel:(id)sender {
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationRepeatCount:1];
wheel.transform = CGAffineTransformMakeRotation(M_PI/4);
[UIView commitAnimations];
returnwheelTimer = [NSTimer scheduledTimerWithTimeInterval:1.1 target:self selector:@selector (returnwheel) userInfo:nil repeats:NO];
}
-(void) returnwheel {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationRepeatCount:1];
wheel.transform = CGAffineTransformMakeRotation(M_PI);
[UIView commitAnimations];
}
真棒感谢您的快速反应,我补充说,它完美的作品 – Xana 2011-04-12 14:20:47