-(CGAffineTransform)getOrientation{
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeRight animated:YES];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft) {
return CGAffineTransformMakeRotation(M_PI*1.5);
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
return CGAffineTransformMakeRotation(M_PI/2);
} else if (orientation == UIInterfaceOrientationPortraitUpsideDown) {
return CGAffineTransformMakeRotation(-M_PI);
} else {
return CGAffineTransformIdentity;
}
}
CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
//开始转换
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
self.view.transform = [self getOrientation];
[UIView commitAnimations];