[英]Iphone-How to rotate image continuously for 30 secs and stop at 180 degrees
I have this so far. 到目前为止,我已经知道了。 I want the image to rotate for about 30 seconds and come to a stop and then face the other way.
我希望图像旋转约30秒钟,然后停下来,然后再朝另一方向走。
edit. 编辑。 Changed the code.
更改了代码。 I have this but it rotates and doesnt stop 180 degrees.
我有这个但是它旋转并且不会停止180度。 I want it to rotate several times and come to stop in the opposite direction.
我希望它旋转几次,然后朝相反的方向停止。
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.duration = 0.60;//animation.duration = 0.60;
animation.repeatCount = 1;//animation.repeatCount = 1000ˆ
//#warning remove comment brackets below
animation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:1.0], nil];
animation.values = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:(degrees / 180)*M_PI], nil];
animation.fillMode = kCAFillModeForwards;
How can I stop the animation with the image still rotated 180 degrees. 如何在图像仍旋转180度的情况下停止动画。
How about 怎么样
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.delegate = self;
animation.autoreverses = YES;
animation.repeatDuration = 30;
animation.duration = 1.0;
animation.fromValue = [NSNumber numberWithFloat:-degreeToRadian(180)];
animation.toValue=[NSNumber numberWithFloat:degreeToRadian(180)];
[self.button.layer addAnimation:animation forKey:@"animation"];
then add a delegate method 然后添加一个委托方法
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
self.button.transform = CGAffineTransformMakeRotation(degreeToRadian(180));
}
I hope this is what you wanted. 希望这就是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.