How to rotate orientation programmatically in Swift?

后端 未结 5 1262
有刺的猬
有刺的猬 2020-12-11 15:53

I tried the next:

UIDevice.currentDevice().setValue(UIInterfaceOrientation.Portrait.rawValue, forKey: \"orientation\")

on

         


        
5条回答
  •  执念已碎
    2020-12-11 16:10

    swift 5

    
    import UIKit
    
    extension UIViewController {
        class func setUIInterfaceOrientation(_ value: UIInterfaceOrientation) {
            UIDevice.current.setValue(value.rawValue, forKey: "orientation")
        }
    }
    
    

提交回复
热议问题