Convert UIImage to NSData and convert back to UIImage in Swift?
UIImage(data:imageData,scale:1.0)
presuming the image's scale is 1.
In swift 4.2, use below code for get Data().
image.pngData()
Thanks. Helped me a lot. Converted to Swift 3 and worked
To save: let data = UIImagePNGRepresentation(image)
To load: let image = UIImage(data: data)
Use imageWithData:
method, which gets translated to Swift as UIImage(data:)
let image : UIImage = UIImage(data: imageData)