Convert a UIImage into NSData BUT stay as a GIF file

前端 未结 3 770
既然无缘
既然无缘 2021-01-01 05:51

I have a UIImage which is a GIF file.

I need to make it make it into an NSData object. But it needs to stay a GIF so I can\'t use UIImageJPEGRepresentation.

3条回答
  •  抹茶落季
    2021-01-01 06:15

    Once it's a UIImage, it's not a gif anymore. It's already been interpreted into a core graphics image object, wrapped in the UIKit trimmings of UIImage. You DON'T have a UIImage that "is a GIF". It may have been once, but that time has passed.

    If you're downloading this thing (which I assume by your comment "I don't have access to the file"), then you should download it as data, and keep it as data, and if you make a UIImage based on that data, you maybe need to keep the data around.

    (This is all a guess, though, because you're dribbling out details about your question drip by drip. If you could say in a bigger breath what you want to accomplish, we can probably help better.)

提交回复
热议问题