由 CyanHall.com
创建于 2020-12-23,
上次更新:2021-03-30。
👉 如果有用请点赞。
来自 StackOverflow: iOS - UIImageView - how to handle UIImage image orientation
👉 如果有用请点赞。
// -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
}
更多