MXRotationManager, 一行代码控制iOS设备旋转方向UIInterfaceOrientationMask

267 阅读1分钟

代码demo已在Github开源, MXRotationManager, 如果能帮助到您,请帮忙点个星star哈,谢谢!

MXRotationManager 一行代码控制iOS设备旋转方向UIInterfaceOrientationMask

屏幕截图

UIDeviceOrientationLandscapeLeft UIDeviceOrientationLandscapeRight
UIDeviceOrientationLandscapeLeft
UIDeviceOrientationLandscapeRight

如何使用

AppDelegate.m里 实现 AppDelegate 代理方法

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return [MXRotationManager defaultManager].interfaceOrientationMask;
}

UIDeviceOrientationLandscapeLeft

[MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeLeft;

UIDeviceOrientationLandscapeRight

    [MXRotationManager defaultManager].orientation = UIDeviceOrientationLandscapeRight;