美文网首页
Orientations

Orientations

作者: iVikings | 来源:发表于2021-12-27 19:08 被阅读0次
    import Foundation
    import UIKit
    
    extension UINavigationController {
        open override var shouldAutorotate: Bool {
            if let vc = self.viewControllers.last {
                return vc.shouldAutorotate
            }
            return false
        }
        
        open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            if let vc = self.viewControllers.last {
                return vc.supportedInterfaceOrientations
            }
            return UIInterfaceOrientationMask.portrait
        }
    }
    
    extension UITabBarController {
        open override var shouldAutorotate: Bool {
            if let select = self.selectedViewController {
                return select.shouldAutorotate
            }
            return false
        }
        
        open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            if let select = self.selectedViewController {
                return select.supportedInterfaceOrientations
            }
            return UIInterfaceOrientationMask.portrait
        }
    }
    

    相关文章

      网友评论

          本文标题:Orientations

          本文链接:https://www.haomeiwen.com/subject/bhoyqrtx.html