title: sublayer with non-finite position [inf inf]
body: <p>I am using a third CocoaPods library written in Objective-C to take a screenshot of a UITextView. It was OK for iOS 8, but after I change the syntax for iOS 9 and Swift 2, it throws an error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'sublayer with non-finite position [inf inf]'</p>
  </blockquote>
  
  <p>Here is the code from the library:</p>
  
  <pre><code>- (UIImage *)screenshotForCroppingRect:(CGRect)croppingRect
  {
      UIGraphicsBeginImageContextWithOptions(croppingRect.size, NO, [UIScreen mainScreen].scale);
      // Create a graphics context and translate it the view we want to crop so
      // that even in grabbing (0,0), that origin point now represents the actual
      // cropping origin desired:
      CGContextRef context = UIGraphicsGetCurrentContext();
      if (context == NULL) return nil;
  
      NSLog(@"hiii :%f" , croppingRect.size.width);
  
      CGContextTranslateCTM(context, -croppingRect.origin.x, -croppingRect.origin.y);
  
      [self layoutIfNeeded];
      [self.layer renderInContext:context];
  
      UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      return screenshotImage;
  }
  </code></pre>
  
  <p>The problem is this line:</p>
  
  <pre><code>[self.layer renderInContext:context];
  </code></pre>
  
  <p>I realize this is because I am trying to take a snapshot of the UIView which contain a UIScrollView. If I remove the UIScrollView subview, the error is gone. </p>
  
  <p>So what does this mean?</p>
  
  <blockquote>
    <p>sublayer with non-finite position [inf inf]</p>
  </blockquote>
  
  <p>Anyone having the same issue and how did you solve it?</p>