Created by CyanHall.com
on 12/23/2020
, Last updated: 03/30/2021.
👉 Star me if it’s helpful.
From StackOverflow: iOS - UIImageView - how to handle UIImage image orientation
👉 Star me if it’s helpful.
// -90 degrees
func rotateImage(image:UIImage) -> UIImage
{
var rotatedImage = UIImage()
switch image.imageOrientation
{
case .right:
rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .up
case .down:
rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .right
case .left:
rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .down
default:
rotatedImage = UIImage(cgImage: image.cgImage!, scale: 1.0, orientation: .left)
}
return rotatedImage
}
More