UIImageWriteToSavedPhotosAlbum save as PNG with transparency?

前端 未结 5 1830
轻奢々
轻奢々 2020-12-02 14:44

I\'m using UIImageWriteToSavedPhotosAlbum to save a UIImage to the user\'s photo album. The problem is that the image doesn\'t have transparency and is a JPG. I\'ve got the

5条回答
  •  孤城傲影
    2020-12-02 15:22

    In Swift 5:

    func pngFrom(image: UIImage) -> UIImage {
        let imageData = image.pngData()!
        let imagePng = UIImage(data: imageData)!
        return imagePng
    }
    

提交回复
热议问题