想象一个中间有一个 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];
谢谢,