Convert UIImage to NSData and convert back to UIImage in Swift?

前端 未结 9 1470
一向
一向 2020-12-02 07:33

I\'m trying to save a UIImage to NSData and then read the NSData back to a new UIImage in Swift. To convert the UII

9条回答
  •  离开以前
    2020-12-02 07:49

    Use imageWithData: method, which gets translated to Swift as UIImage(data:)

    let image : UIImage = UIImage(data: imageData)
    

提交回复
热议问题