2009-10-10 132 views
0

任何有关如何顺时针/逆时针旋转图像的想法。顺时针/逆时针旋转图像

+0

您需要提供更多信息。你有没有工作的代码,或者你在寻找从哪里开始的想法? – ChrisF 2009-10-10 11:51:29

回答

0

你会想为此使用CoreAnimation;基本上,您需要将动画应用于图像视图的transform属性。 Apple的开发者页面上有大量的samples,显示了这个变化。

4
#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

0

这可能是已故的回答你的问题,但它会帮助别人..
通过使用CGAffineTransformMakeRotation我们可以能够将图像旋转

旋转逆时针方向的图像

-(void)rotate 
    { 
     x++; 
     CGAffineTransform transform = CGAffineTransformMakeRotation(x); 
     imageView.transform = transform; 
     [self performSelector:@selector(rotate) withObject:self afterDelay:0.1]; 

    } 

对于顺时针方向使用x--;

相关问题