2011-09-11 76 views
0

当我旋转我的应用程序时,背景图片不会旋转,并且我希望我的背景图片会旋转。 内容确实会改变方向,但背景图像保持不变并且不会旋转。如何让背景图片旋转?

任何想法都有问题吗?

谢谢。

回答

1

这个想法是在设备旋转时应用图形“变换”来修改图像。看到这个答案here ...在你的图像控制器,添加以下代码(其中将backgroundImage是包含图像的属性。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
           duration:(NSTimeInterval)duration { 

    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { 
     backgroundImage.transform = CGAffineTransformMakeRotation(M_PI/2); 
    } 
    else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){ 
     backgroundImage.transform = CGAffineTransformMakeRotation(-M_PI/2); 
    } 
    else { 
     backgroundImage.transform = CGAffineTransformMakeRotation(0.0); 
    } 
} 
+0

虽然这是停止了转动,我会做出改变,使其旋转的方式 –