iPhone + CGAffineTransFormRotate(pi/2) + statusBarHidden:YES + presentModalViewController = 20 pixels of white space

前端 未结 3 1373
深忆病人
深忆病人 2021-01-01 07:33

I think the title is pretty descriptive:

I perform all 3 of these operations on a view, the result is 20 pixels of white space along the left side of the screen (if

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 08:05

    I think you may need to recenter your center:

    // Set the center point of the view to the center point of the window's content area.      
    self.view.center = CGPointMake(160.0, 240.0);
    

    This is the whole init method I use for landscape views and works without an issue. Just make sure to set your nib to the right size too.

    // Implement viewDidLoad to do additional setup after loading the view.
    - (void)viewDidLoad {
      [super viewDidLoad];
    
      // Rotate to landscape
      self.view.frame = CGRectMake(0, 0, 480.0, 320.0);
      if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
        CGAffineTransform transform = self.view.transform;
    
        // Set the center point of the view to the center point of the window's content area.      
        self.view.center = CGPointMake(160.0, 240.0);
    
        // Rotate the view 90 degrees around its new center point.
        transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
        self.view.transform = transform;
      }
    }
    

提交回复
热议问题