Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: sharing a transparent UIImage w/ UIActivityViewController?

So I am using UIActivityViewController to let users share or save an image they create with my app. I include a UIImage as one of the share items, it all works fine.

Except: it is possible to create this image with some transparent areas. And it looks to me like the built-in UIActivities all create JPEG representations of the UIImage, thus losing the transparency.

Is there a way to force it to use a PNG representation so as not to lose the alpha channel?

like image 812
DanM Avatar asked Oct 19 '25 09:10

DanM


1 Answers

Without seeing some code it may be difficult to fully answer the question. Have you tried converting your UIImage to an NSData object using UIImagePNGRepresentation and sharing the NSdata object instead of the image itself? I would have put this in a comment rather than an answer, but I lack the rep.

Reference for UIImagePNGRepresentation: https://developer.apple.com/library/ios/documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIImagePNGRepresentation

like image 110
jrisberg Avatar answered Oct 22 '25 02:10

jrisberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!