title: iOS Get Screenshot Of Visible Portion of a UITableView
body: <p>I'm trying to get my app to take a screenshot of a view (a table view). This is the code I use to do this:</p>
  
  <pre><code>if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
      UIGraphicsBeginImageContextWithOptions(self.tableView.frame.size, NO, [UIScreen mainScreen].scale); //retina display
  else
      UIGraphicsBeginImageContext(self.tableView.frame.size);
  [self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
  UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>This works, but only if the table view is scrolled to the very top, if it's not, the image is black. The only solutions to this that I have found is for capturing the entire table view. I only need the visible portion. How would I do this?</p>