Last active
January 22, 2020 07:35
-
-
Save leviathan/c44c6971c48dca055266c831e1e16e71 to your computer and use it in GitHub Desktop.
UIImage quick file dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Quickly dump a UIImage from memory into a tmp file. | |
var image: UIImage? | |
// ... | |
let imageFilePath = NSTemporaryDirectory() + "\(Date().timeIntervalSince1970).png" | |
try? image.pngData()!.write(to: URL(fileURLWithPath: imageFilePath)) | |
print("Saved turn-by-turn advice image to: \(imageFilePath)") | |
/// UIView to UIImage | |
let renderer = UIGraphicsImageRenderer(size: view.bounds.size) | |
let image = renderer.image { ctx in | |
view.drawHierarchy(in: view.bounds, afterScreenUpdates: true) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment