美文网首页
UIImage图片转成Base64字符串

UIImage图片转成Base64字符串

作者: JohnayXiao | 来源:发表于2017-08-04 08:59 被阅读13次
    //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];
    

    相关文章

      网友评论

          本文标题:UIImage图片转成Base64字符串

          本文链接:https://www.haomeiwen.com/subject/fsxvlxtx.html