我花了一段時間來理解這個概念。我不想創建相同的圖像肖像和風景。這裏的關鍵是CGAffineTransformMakeRotation
從你的UIImageView或任何UIView的原始狀態旋轉。這假定你的背景圖像有定位。例如。你希望你的UIImageView保持放置,而其他對象的行爲正常的方向更改事件。
- (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);
}
}
究竟你「一刀切」的意思麼?一張照片會有幫助。 – colithium 2010-09-24 10:21:48
縱向模式下我的圖像爲768x1004。在橫向模式下,它仍然是768px寬而不是1024px。我會發佈一個屏幕。 – Salah 2010-09-24 11:58:29
下面是肖像截圖:http://img202.imageshack.us/img202/9617/screenshot20100924at141.png和風景:http://img832.imageshack.us/img832/9617/screenshot20100924at141.png – Salah 2010-09-24 12:15:51