MXRotationManager, 一行程式碼控制iOS裝置旋轉方向UIInterfaceOrientationMask

穿山甲到底說了什麼發表於2018-12-19

程式碼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;

複製程式碼

相關文章