【问题标题】:How to rotate image with location or other如何使用位置或其他旋转图像
【发布时间】:2012-07-28 21:17:59
【问题描述】:

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

谢谢,

【问题讨论】:

    标签: objective-c ios5 xcode4.3


    【解决方案1】:

    查看 UIViewController 的方法:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多