Created
October 23, 2019 04:00
-
-
Save trilliwon/e9c9554825b79b4c078fa9819f571143 to your computer and use it in GitHub Desktop.
UIDeviceOrientation to Image Orientation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIDeviceOrientation { | |
var imageOrientation: UIImage.Orientation { | |
switch UIDevice.current.orientation { | |
case .landscapeLeft: | |
return UIImage.Orientation.right | |
case .landscapeRight: | |
return UIImage.Orientation.left | |
case .portrait: | |
return UIImage.Orientation.up | |
case .portraitUpsideDown: | |
return UIImage.Orientation.down | |
default: | |
return UIImage.Orientation.up | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment