【发布时间】:2011-08-03 22:35:15
【问题描述】:
我正在尝试做一些相对简单的事情,当用户触摸按钮时让轮子旋转 90 度,到目前为止我所做的大部分工作都是第一次工作,但此后图像不会移动。我希望它保持新位置,然后从新位置旋转 90 度,我有 [UIView setAnimationBeginsFromCurrentState:YES];
但这似乎不起作用
我添加了一个 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];
}
【问题讨论】:
标签: objective-c xcode ipad ios4