顺时针/逆时针旋转图像
答
#import <QuartzCore/QuartzCore.h>
[UIView beginAnimations:@"RotationAnimation" context:nil];
CABasicAnimation *fullRotationAnimation;
fullRotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotationAnimation .fromValue = [NSNumber numberWithFloat:0];
fullRotationAnimation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotationAnimation.duration = 2; // speed for the rotation. Smaller number is faster
fullRotationAnimation.repeatCount = 1e100f; // number of times to spin. 1 = once
[myImage.layer addAnimation:fullRotationAnimation forKey:@"360"];
[UIView commitAnimations];
+2
实际上,我不相信UIView的开始/提交动画块在这里是必要的,因为你明确地为视图的层设置了动画。您可能还想使用“transform.rotation.z”作为动画的关键路径,以清楚地指定旋转的轴。 – 2009-10-10 23:24:35
答
这可能是已故的回答你的问题,但它会帮助别人..
通过使用CGAffineTransformMakeRotation我们可以能够将图像旋转
旋转逆时针方向的图像
-(void)rotate
{
x++;
CGAffineTransform transform = CGAffineTransformMakeRotation(x);
imageView.transform = transform;
[self performSelector:@selector(rotate) withObject:self afterDelay:0.1];
}
对于顺时针方向使用x--;
您需要提供更多信息。你有没有工作的代码,或者你在寻找从哪里开始的想法? – ChrisF 2009-10-10 11:51:29