iOS开发之图片base64编码处理

// 64base字符串转图片

- (UIImage *)stringToImage:(NSString *)str

{

    NSData * imageData =[[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];

    UIImage *photo = [UIImage imageWithData:imageData ];

    return photo;

}

 

// 图片转64base字符串

- (NSString *)imageToString:(UIImage *)image

{

    NSData *imagedata = UIImagePNGRepresentation(image);

    NSString *image64 = [imagedata base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

    return image64;

}

posted @ 2019-08-14 15:40  kawerd  阅读(2903)  评论(0编辑  收藏  举报