base64标准格式可以用以下方法:
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64Str options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *image = [UIImage imageWithData:imageData];
base64字符串有图片前缀(前缀类似:data:image/jpeg;base64,xxxxxxx)用以下方法:
NSURL *baseImageUrl = [NSURL URLWithString:base64Str];
NSData *imageData = [NSData dataWithContentsOfURL:baseImageUrl];
UIImage *image = [UIImage imageWithData:imageData];
网友评论