How to rotate image in Swift?

后端 未结 13 1216
萌比男神i
萌比男神i 2020-11-30 03:55

I am unable to rotate the image by 90 degrees in swift. I have written below code but there is an error and doesn\'t compile

  func imageRotatedByDegrees(old         


        
相关标签:
13条回答
  • 2020-11-30 04:21
    UIGraphicsBeginImageContext(CGSize(width: bitmap.width, height: bitmap.height))
    UIImage(cgImage: oldImage.cgImage, scale: 1, orientation: .leftMirrored).draw(at: .zero)
    let image = UIGraphicsGetImageFromCurrentImageContext()!
    

    Much shorter.

    0 讨论(0)
提交回复
热议问题