How to rotate orientation programmatically in Swift?

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

I tried the next:

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

on

         


        
5条回答
  •  粉色の甜心
    2020-12-11 16:24

    To change orientation programatically in swift 3, use the following way:

    let value = UIInterfaceOrientation.landscapeRight.rawValue
    UIDevice.current.setValue(value, forKey: "orientation")
    

    You can use the orientations,

    1. portrait 2. portraitUpsideDown 3. landscapeLeft 4. landscapeRight

提交回复
热议问题