iOS屏幕旋转方法

1 . 比较好的旋转屏幕的方法如下:

[[UIDevice currentDevice] setValue:@(UIDeviceOrientationLandscapeLeft)forKey:@"orientation"];

这样做的话在模拟器中会发现模拟器也随着变成了横屏

2 .通过setTransform使用户感觉屏幕旋转

    CGFloat height = [[UIScreen mainScreen] bounds].size.width;
    CGFloat width = [[UIScreen mainScreen] bounds].size.height;
    CGRect frame = CGRectMake((height - width) / 2, (width - height) / 2, width, height);;
    [UIView animateWithDuration:0.3f animations:^{
        [self.view setTransform:CGAffineTransformMakeRotation(M_PI_2)];
    } completion:^(BOOL finished) {
  
    }];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容