UIImageWriteToSavedPhotosAlbum save as PNG with transparency?

前端 未结 5 1829
轻奢々
轻奢々 2020-12-02 14:44

I\'m using UIImageWriteToSavedPhotosAlbum to save a UIImage to the user\'s photo album. The problem is that the image doesn\'t have transparency and is a JPG. I\'ve got the

5条回答
  •  误落风尘
    2020-12-02 15:21

    As pointed out on this SO question there is a simple way to save pngs in your Photo Albums:

    UIImage* image = ...;                                     // produce your image
    NSData* imageData =  UIImagePNGRepresentation(image);     // get png representation
    UIImage* pngImage = [UIImage imageWithData:imageData];    // rewrap
    UIImageWriteToSavedPhotosAlbum(pngImage, nil, nil, nil);  // save to photo album
    

提交回复
热议问题