How to display a base64 image within a UIImageView?

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

I got this Base64 gif image:

R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmN         


        
11条回答
  •  旧巷少年郎
    2020-11-30 01:32

    This Code will display an base64 encoded string as a picture:

    NSString *str = @"data:image/jpg;base64,";
    str = [str stringByAppendingString:restauInfo.picture];
    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
    

    restauInfo.picture is an NSString which contains the base64 encoded JPG

    In my case the Value from "restauInfo.picture" comes from a database

提交回复
热议问题