2012-07-28 58 views
0

想象一下在中间有一个UIImageView的UIView,当我旋转iphone时图像仍然朝上,这意味着当我将iPhone旋转到右侧时,UIImageView向左旋转在同样的程度上。我曾见过一些像iAngle Meter这样的应用程序使用这个选项,所以我该怎么做?如何用位置图或其他方式旋转图像

Pd。我只知道如何旋转图像,我用:

#define M_PI 3.14159265358979323846264338327950288 //pi 
#define DEGREES_TO_RADIANS(angle) (angle/180.0 * M_PI) 

- (void)rotateImage: (UIImageView *)image duration:(NSTimeInterval)duration curve:(int)curve degrees:(CGFloat)degrees { 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:duration]; 
[UIView setAnimationCurve:curve]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 

CGAffineTransform transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees)); 
image.transform = transform; 

[UIView commitAnimations]; 
} 

申请行:

[self rotateImage:logoAnim duration:0.5 curve:UIViewAnimationCurveEaseIn degrees:-30]; 

感谢,

回答

0

查找到UIViewController的方法:

 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orientation 
              duration:(NSTimeInterval)duration { 

    } 

它将通知你什么时候开始旋转到你已经通过info.plist启用你的应用程序的方向d in -shouldRotateToInterfaceOrientation:方法。