0

想象一个中间有一个 UIImageView 的 UIView,当我旋转 iphone 时,图像仍然向上看,这意味着当我向右旋转 iphone 时, UIImageView 以相同的度数向左旋转。我见过一些应用程序,比如 iAngle Meter 使用这个选项,那么我该怎么做呢?

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

#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];

谢谢,

4

1 回答 1

0

查看 UIViewController 的方法:

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

     }

它会在何时开始旋转到您通过 info.plist 和 -shouldRotateToInterfaceOrientation: 方法启用到您的应用程序的方向时通知您。

于 2012-07-28T22:30:29.260 回答