UIImage图片转成Base64字符串

2017-08-04  本文已影响13人  JohnayXiao
//UIImage图片转成Base64字符串:
UIImage *originImage = [UIImage imageNamed:@"originImage.png"];
NSData *data = UIImageJPEGRepresentation(originImage, 1.0f);
NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    
//Base64字符串转UIImage图片:
NSData *decodedImageData = [[NSData alloc] 
initWithBase64EncodedString:encodedImageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *decodedImage = [UIImage imageWithData:decodedImageData];
上一篇下一篇

猜你喜欢

热点阅读