问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/24689926/ios-sharing-a-transparent-uiimage-w-uiactivityviewcontroller