首页 > 代码库 > ios 开发之 各种数据类型之间转换 (持续补充)

ios 开发之 各种数据类型之间转换 (持续补充)

1.图片转base64串及反转回图片

UIImage图片转成base64字符串:

1 UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];2 NSData *_data = http://www.mamicode.com/UIImageJPEGRepresentation(_image, 1.0f);
3 NSString *_encodedImageStr = [_data base64Encoding];4 NSLog(@"===Encoded image:\n%@", _encodedImageStr);

Base64字符串转UIImage图片:

1 NSData *_decodedImageData   =http://www.mamicode.com/ [[NSData alloc] initWithBase64Encoding:_encodedImageStr];2 UIImage *_decodedImage      = [UIImage imageWithData:_decodedImageData];3 NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));

 

 

ios 开发之 各种数据类型之间转换 (持续补充)