iOS UIImage图片Base64字符串互转
作者:
zzcz_cc | 来源:发表于
2018-01-06 11:44 被阅读0次// UIImage图片转成Base64字符串:
UIImage *originImage = image;
NSData *data = UIImageJPEGRepresentation(originImage, 1.0f);
NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
NSLog(@"encodedImageStr==%@",encodedImageStr);
// Base64字符串转UIImage图片:
NSData *decodedImageData = [[NSData alloc]initWithBase64EncodedString:encodedImageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *decodedImage = [UIImage imageWithData:decodedImageData];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 100, 200, 400)];
[imgView setImage:decodedImage];
[self.view addSubview:imgView];
NSLog(@"decodedImage==%@",decodedImageData);
本文标题:iOS UIImage图片Base64字符串互转
本文链接:https://www.haomeiwen.com/subject/sdqynxtx.html
网友评论