iOS 使用base64字符串生成图片

字符串

po str
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAAHeCAYAAAA1nmrDAAA+G0lEQVR4Xu3VQa5rS44l0Zz/pKsat2cfML2NIOV0FxdgnQQ2nDr3Z7z/+39rrbXW+pr/4/9hrbXWWn32H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64v2H9611lrri/Yf3rXWWuuL9h/etdZa64tG/cP7f//3f1tYF75zogS3J+rCd6wufOdECW6t2/D+7XPTjLqIH2v7XBe+c6IEtyfqwnesLnznRAlurdvw/u1z04y6iB9r+1wXvnOiBLcn6sJ3rC5850QJbq3b8P7tc9OMuogfa/tcF75zogS3J+rCd6wufOdECW6t2/D+7XPTjLqIH2v7XBe+c6IEtyfqwnesLnznRAlurdvw/u1z04y6iB9r+1wXvnOiBLcn6sJ3rC5850QJbq3b8P7tc9OMuogfa/tcF75zogS3J+rCd6wufOdECW6t2/

+ (UIImage *)stringToImage:(NSString *)str {
    NSURL *baseImageUrl = [NSURL URLWithString:str];
    NSData *imageData = [NSData dataWithContentsOfURL:baseImageUrl];
    UIImage *photo = [UIImage imageWithData:imageData ];
    return photo;
}

你可能感兴趣的:(ios,objective-c,xcode)