图片转base64
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]];
UIImage *img = [UIImage imageWithData:data];
NSString *img64 = [self encodeToBase64String:img];
- (NSString *)encodeToBase64String:(UIImage *)image{
NSString * test = [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
return test;
}
base64转图片
NSData *data = [[NSData alloc]initWithBase64EncodedString:base64Str options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *img = [UIImage imageWithData:data];