title: Render UIView to image without subviews
body: <p>I want to convert a UIView to a UIImage</p>
  
  <pre><code>- (UIImage *)renderToImage:(UIView *)view {
    if(UIGraphicsBeginImageContextWithOptions != NULL) {
      UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0);
    } else {
      UIGraphicsBeginImageContext(view.frame.size);
    }
  
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
  }
  </code></pre>
  
  <p>Two questions:</p>
  
  <ol>
  <li><p>I have subviews on my view. Is there a way to create an image of the view without any of the subviews? Ideally id like to not have to remove them just to add them back later.</p></li>
  <li><p>Also, it isn't rendering the images properly on retina devices. I followed the advice here to use context with options but it did not help. <a href="https://stackoverflow.com/questions/4334233/how-to-capture-uiview-to-uiimage-without-loss-of-quality-on-retina-display">How to capture UIView to UIImage without loss of quality on retina display</a></p></li>
  </ol>