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) {
}];
网友评论