2011-09-11 82 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

雖然這是停止了轉動,我會做出改變,使其旋轉的方式 –