0

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

iOS Developer
  • 538
  • 4
  • 10
Allen
  • 27
  • 1
  • 7
  • see this - https://stackoverflow.com/questions/40854886/swift-take-a-photo-and-save-to-photo-library – Rashed Mar 04 '18 at 07:55
  • tell me if this doesn't works for you https://stackoverflow.com/questions/12161298/how-to-take-screenshot-of-uiimageview-in-iphone-sdk – iOS Developer Mar 04 '18 at 08:07
  • i think it work but there is something else in my code effect it causing the error its probably answer @iOSDeveloper – Allen Mar 04 '18 at 10:00

0 Answers0