快速連結

2011年12月1日

在一般ViewController內依照旋轉有不同的背景圖

在ViewController.m內寫上:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    
    //轉向的話要不一樣
    if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"橫.png"]];
 } else if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ) {
  self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"直.png"]];
 }
    // Return YES for supported orientations
    return YES;
}