Capture iPhone screen with status bar included?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2009-08-17T23:58:29Z Indexed on 2010/06/17 10:43 UTC
Read the original article Hit count: 347

I am looking for a way to capture a screenshot on the iPhone with the top status bar included, I am currently using the following code:

    UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

The above code sucessfully takes a screenshot of the iPhone UIView but does not include the top status bar (In its place is just a blank 20px space).

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c