iOS: sharing a transparent UIImage w/ UIActivityViewController?

折月煮酒 提交于 2019-12-10 10:56:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!