如何将UIImageView转换为CGImageRef?

时间:2016-07-02 00:33:45

标签: ios objective-c uiimageview

CGImageRef inImage = (__bridge CGImageRef)(self.captureImage.image);
NSLog(@"%zu",inImage);

为什么这不起作用? 它说" NULL"。 如何将image更改为CGImageRef

1 个答案:

答案 0 :(得分:1)

假设self.captureImage是您的(名字不详)UIImageView,那么您需要:

CGImageRef inImage = self.captureImage.image.CGImage;

更清楚:

UIImageView *imageView = self.captureImage;
UIImage *image = imageView.image;
CGImageRef inImage = image.CGImage;