Hide buttons when making a screenshot UIGraphicsBeginImageContextWithOptions
- by Jan
is there a way to hide specific buttons (IBAction) when making a screenshot with UIGraphicsBeginImageContextWithOptions ?
I'm using the code below:
// Define the dimensions of the screenshot you want to take (the entire screen in this case)
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sourceImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//now we will position the image, X/Y away from top left corner to get the portion we want
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[sourceImage drawAtPoint:CGPointMake(0, -20)];
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(croppedImage,nil, nil, nil);
Thank you for your answer!