CyanHall.com 创建于 2020-12-23, 上次更新:2021-03-30。
👉  github shields 如果有用请点赞。
    // -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
}
  
来自 StackOverflow: iOS - UIImageView - how to handle UIImage image orientation
Maitained by Cyanhall.com, Copy Rights @ CC BY-NC-SA 4.0     ExcelRoadMap