iOS UIImagePickerController result image orientation after upload

后端 未结 20 1948
长发绾君心
长发绾君心 2020-11-22 00:44

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController:

UIImagePickerCont         


        
20条回答
  •  名媛妹妹
    2020-11-22 01:22

    Swift 4.x/5.0 version of @an0 's solution:

    extension UIImage {
        func upOrientationImage() -> UIImage? {
            switch imageOrientation {
            case .up:
                return self
            default:
                UIGraphicsBeginImageContextWithOptions(size, false, scale)
                draw(in: CGRect(origin: .zero, size: size))
                let result = UIGraphicsGetImageFromCurrentImageContext()
                UIGraphicsEndImageContext()
                return result
            }
        }
    }
    

提交回复
热议问题