title: Capturing full screenshot with status bar in iOS programmatically
body: <p>I am using this code to capture a screenshot and to save it to the photo album.</p>
  
  <pre><code>-(void)TakeScreenshotAndSaveToPhotoAlbum
  {
     UIWindow *window = [UIApplication sharedApplication].keyWindow;
  
     if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
         UIGraphicsBeginImageContextWithOptions(window.bounds.size, NO, [UIScreen mainScreen].scale);
     else
         UIGraphicsBeginImageContext(window.bounds.size);
  
     [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
     UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
     UIGraphicsEndImageContext();
  
     UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
  }
  </code></pre>
  
  <p>But the problem is whenever the screenshot is saved, I see the status bar of iPhone is not captured. Instead a white space appears at the bottom. Like the following image:
  <img src="https://i.stack.imgur.com/eH3T0.png" alt="enter image description here"></p>
  
  <p>What am I doing wrong?</p>