1. UIImage转换成base64
NSData *imageData = UIImageJPEGRepresentation([_imageView image], 0.5f);
NSString *base64ImageString = [imageData base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithCarriageReturn];
[_textBox setText:base64ImageString];2. base64转换UIImage
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:[_textBox text] options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[_imageView setImage:image];
推荐一个在线转换base64与图片, 很方便大家测试时使用. http://www.vgot.net/test/image2base64.php?

本文介绍如何在iOS开发中将UIImage转换为Base64字符串及反之的详细步骤,并提供了一个在线测试工具链接。

239

被折叠的 条评论
为什么被折叠?



