Maintain transparency in iOS screenshot

I am taking a screenshot of a certain kind in my Xib file with the following code ...

UIView* captureView = self.view;
UIGraphicsBeginImageContextWithOptions(captureView.bounds.size, NO , 0.0f);
[captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

It works great and saves a jpg image in a camera roll.

But the problem is that at the top of my view there is another UIImageView, which UIImageView has a translucent image in it. My screenshot does not preserve this transparency in the screenshot. I want to maintain transparency, as on a real screen.

How to maintain transparency in the screenshot?

+4
source share
4 answers

"" , - . , -.

+3

JPG , , JPG, . UIImageWriteToSavedPhotosAlbum

png.

+2

.

  UIGraphicsBeginImageContext(baseViewOne.frame.size);
            [[baseViewOne layer] renderInContext:UIGraphicsGetCurrentContext()];
            UIImage * screenshota = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();

cocoa

+1
NSData* imdata = UIImagePNGRepresentation(_snapshotImgView.image);
UIImage* snapshotPNG = [UIImage imageWithData:imdata];

UIImageWriteToSavedPhotosAlbum(snapshotPNG, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
0

All Articles