Quote:
Originally Posted by sacha1996
Hi,
You can use this code to capture a screen:
Code:
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
UIGraphicsEndImageContext();
But let's say I have a How can I make a screen capture without the button1 in it?
Is there a way to cut this from the capture?
Thanks!
|
Hide the button, take the screen capture, and un-hide the button?
You would need to pause for an instant after hiding the button in order to let the screen re-draw. Something like this
Code:
button1.hidden = TRUE;
[self performSelector: screenSnapshot withObject: nil afterDelay: 0];
(A delay of 0 still lets the system return and go through the event loop, where your graphics changes take effect.)
Code:
- (void) screenSnapshot;
{
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
UIGraphicsEndImageContext();
button1.hidden = false;
}