Quantcast
Viewing all articles
Browse latest Browse all 10

Answer by Samo for How do I save a UIImage to a file?

In Swift 4:

// Create path.let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)if let filePath = paths.first?.appendingPathComponent("MyImageName.png") {    // Save image.    do {       try UIImagePNGRepresentation(image)?.write(to: filePath, options: .atomic)    }    catch {       // Handle the error    }}

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>