How to autorotate from portrait to landscape mode?

后端 未结 3 981
一生所求
一生所求 2021-01-28 23:00

How can I autorotate an image from portrait to landscape mode on the IPhone?

3条回答
  •  死守一世寂寞
    2021-01-28 23:36

    Apply proper transformation to the view and adjust its frame bounds

    In my app I've done it this way (very likely not the best one):

    [UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration: 0.5f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    
    self.view.transform = CGAffineTransformIdentity;
    self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
    self.view.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);
    
    self.view.center = CGPointMake(160.0f, 240.0f);
    [UIView commitAnimations];
    

提交回复
热议问题