NSData和UIImage

我们从网络上下载的NSData类型的图片数据,怎么展示为UIImage类型的?

UIImage has an -initWithData:
 method. From the docs: "The data in the data parameter must be formatted to match the file format of one of the system’s supported image types."```

- NSData转换为UIImage

NSData *imageData = UIImagePNGRepresentation(image);
UIImage *image=[UIImage imageWithData:data];```

  • UIImage转换为NSData
UIImage *img = [UIImage imageNamed:@"image.png"];
NSData *data1 = UIImagePNGRepresentation(img);```

你可能感兴趣的:(NSData和UIImage)