我的应用程序仅在人像模式下受支持。我要求UIView
仅根据设备方向旋转特定对象。
你能帮我么?
经过长时间的尝试,我发现使用CGAffineTransform
..的答案
- (void)deviceOrientationDidChange:(NSNotification *)notification {
//Obtain current device orientation
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
CGFloat angle;
switch (orientation) {
case UIDeviceOrientationPortraitUpsideDown:
angle = M_PI;
break;
case UIDeviceOrientationLandscapeRight:
angle = - M_PI_2;
break;
case UIDeviceOrientationLandscapeLeft:
angle = M_PI_2;
break;
case UIDeviceOrientationPortrait:
default:
angle = 0.f;
break;
}
animationView.transform= CGAffineTransformMakeRotation(angle);
animationView.frame = self.view.frame;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句