Hey I've looked at a lot of other question and tried to combine things to get the result but I have no luck.
Code:
UIGraphicsBeginImageContextWithOptions(self.ImageView.frame.size, false, UIScreen.main.scale)
// Draw view in that context
self.ImageView.drawHierarchy(in: self.ImageView.bounds, afterScreenUpdates: true)
// And finally, get image
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let imageRepresentation = UIImagePNGRepresentation(image)
let imageData = UIImage(data: imageRepresentation!)
UIImageWriteToSavedPhotosAlbum(imageData!, nil, nil, nil)
Sometimes I get this error and other times I don't. Is there a way to check to see if it would throw an error before? Also, I have never seen this error and really don't know what it is telling me
Error:
9: failed assertion `Fragment Function(ca_uber_fragment_lp0_cp1_fo0): The pixel format (MTLPixelFormatRGBA16Unorm) of the texture (name:) bound at index 0 is incompatible with the data type (MTLDataTypeHalf) of the texture parameter (img_tex_0A [[texture(0)]]). MTLPixelFormatRGBA16Unorm is compatible with the data type(s) (
The times that it doesn't crash with this error it works perfectly