How to display a base64 image within a UIImageView?

后端 未结 11 2176
攒了一身酷
攒了一身酷 2020-11-30 00:56

I got this Base64 gif image:

R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmN         


        
11条回答
  •  再見小時候
    2020-11-30 01:51

    Very old question, but as of iOS7 there is a new, much easier way to do so, hence I'm writing it here so future readers can use this.

    NSData* data = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
    UIImage* image = [UIImage imageWithData:data];
    

    Very easy to use, and will not hit the 2048 byte size limit of a URL.

提交回复
热议问题