I want a screenshot of the image on the screen saved into the saved photo library.
As of iOS10, this gets a bit simpler. UIKit comes with UIGraphicsImageRender
that allows you to
... accomplish drawing tasks, without having to handle configuration such as color depth and image scale, or manage Core Graphics contexts
Apple Docs - UIGraphicsImageRenderer
So you can now do something like this:
let renderer = UIGraphicsImageRenderer(size: someView.bounds.size)
let image = renderer.image(actions: { context in
someView.drawHierarchy(in: someView.bounds, afterScreenUpdates: true)
})
Many of the answers here worked for me in most cases. But when trying to take a snapshot of an ARSCNView
, I was only able to do it using the method described above. Although it might be worth noting that at this time, ARKit is still in beta and Xcode is in beta 4