title: UIImageView screenshot clipping with subviews
body: <p>I am trying to screenshot a UIImageView which has alpha (love heart with alpha transparency for the heart, black edges) which is moveable, scalable and rotatable - on top of a UIImageView which doesn't move.</p>
  
  <p>What I'm trying to accomplish is allowing the user to move the heart shape on top (already got the code working for that) - then when they click a next button, it will take a screenshot of the heart shape and also capture the image underneath. I have this code passing through the screenshotted image to a segue. This is what I have so far and this is the result.</p>
  
  <p>Here is my current code and the before/afters:</p>
  
  <p><code>moveableMaskImageView</code> is the Heart UIImageView<br>
  <code>outletPreview</code> is the UIImageView underneath</p>
  
  <pre><code>#pragma screenshotImage:
  - (UIImage *)screenShotImage {
  CGRect rect = [moveableMaskImageView frame];
  NSLog(@"Screenshot X: %f Screenshot Y: %f Screenshot W: %f Screenshot H: %f",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
  UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0f);
  CGContextRef context = UIGraphicsGetCurrentContext();
  [outletPreview.layer renderInContext:context];
  [moveableMaskImageView.layer renderInContext:context];
  UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  return capturedImage;
  }
  </code></pre>
  
  <p><strong>Before (Positioning):</strong></p>
  
  <p><img src="https://i.stack.imgur.com/RBGbr.png" alt="Before"></p>
  
  <p><strong>After:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/A2SH6.png" alt="After"></p>