title: Determine if crop rect is entirely contained within rotated UIView
body: <p>Premise: I'm building a cropping tool that handles two-finger arbitrary rotation of an image as well as arbitrary cropping.</p>
  
  <p>Sometimes the image ends up rotated in a way that empty space is inserted to fill a gap between the rotated image and the crop rect (see the examples below).</p>
  
  <p>I need to ensure that the image view, when rotated, fits entirely into the cropping rectangle. If it doesn't, I then need to re-transform the image (zoom it) so that it fits into the crop bounds.</p>
  
  <p>Using <a href="https://stackoverflow.com/questions/15710853/objective-c-check-if-subviews-of-rotated-uiviews-intersect">this answer</a>, I've implemented the ability to check whether a rotated UIImageView intersects with the cropping CGRect, but unfortunately that doesn't tell me if the crop rect is <strong>entirely</strong> contained in the rotated imageview. Hoping that I can make some easy modifications to this answer?</p>
  
  <p>A visual example of OK:</p>
  
  <p><img src="https://i.stack.imgur.com/YaRqv.png" alt="enter image description here"></p>
  
  <p>and not OK, that which I need to detect and deal with:</p>
  
  <p><img src="https://i.stack.imgur.com/WLvvl.png" alt="enter image description here"></p>
  
  <p><strong>Update:</strong> not working method</p>
  
  <pre><code>- (BOOL)rotatedView:(UIView*)rotatedView containsViewCompletely:(UIView*)containedView {
  
      CGRect rotatedBounds = rotatedView.bounds;
      CGPoint polyContainedView[4];
  
      polyContainedView[0] = [containedView convertPoint:rotatedBounds.origin toView:rotatedView];
      polyContainedView[1] = [containedView convertPoint:CGPointMake(rotatedBounds.origin.x + rotatedBounds.size.width, rotatedBounds.origin.y) toView:rotatedView];
      polyContainedView[2] = [containedView convertPoint:CGPointMake(rotatedBounds.origin.x + rotatedBounds.size.width, rotatedBounds.origin.y + rotatedBounds.size.height) toView:rotatedView];
      polyContainedView[3] = [containedView convertPoint:CGPointMake(rotatedBounds.origin.x, rotatedBounds.origin.y + rotatedBounds.size.height) toView:rotatedView];
  
      if (CGRectContainsPoint(rotatedView.bounds, polyContainedView[0]) &amp;&amp;
          CGRectContainsPoint(rotatedView.bounds, polyContainedView[1]) &amp;&amp;
          CGRectContainsPoint(rotatedView.bounds, polyContainedView[2]) &amp;&amp;
          CGRectContainsPoint(rotatedView.bounds, polyContainedView[3]))
          return YES;
      else
          return NO;
  }
  </code></pre>