Orientation improvements

This commit is contained in:
Arkadiusz Fal
2022-07-10 00:29:13 +02:00
parent 6c71cd72b1
commit 5f858bc6d4
8 changed files with 144 additions and 138 deletions

View File

@@ -21,11 +21,16 @@ struct Orientation {
static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation: UIInterfaceOrientation? = nil) {
lockOrientation(orientation)
guard !rotateOrientation.isNil else {
guard let rotateOrientation = rotateOrientation else {
return
}
UIDevice.current.setValue(rotateOrientation!.rawValue, forKey: "orientation")
let orientationString = rotateOrientation == .portrait ? "portrait" : rotateOrientation == .landscapeLeft ? "landscapeLeft" :
rotateOrientation == .landscapeRight ? "landscapeRight" : rotateOrientation == .portraitUpsideDown ? "portraitUpsideDown" : "allButUpsideDown"
logger.info("rotating to \(orientationString)")
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
UINavigationController.attemptRotationToDeviceOrientation()
}
}