sublayer with non-finite position

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:

Terminating app due to uncaught exception ‘CALayerInvalidGeometry’, reason: ‘sublayer with non-finite position [inf inf]’

  • winSize] is wrong
  • SKPhysicsBody from Texture gives null on collision in Spritekit
  • swift : Failed to communicate with Interface Builder
  • Xcode AVCapturesession scan Barcode in specific frame (rectOfInterest is not working)
  • Using C++ to access Documents folder on iOS
  • UIWebView Keyboard - Getting rid of the “Previous/Next/Done” bar
  • Here is the code from the library:

    - (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();
        return screenshotImage;

    The problem is this line:

    [self.layer renderInContext:context];

    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.

    So what does this mean?

    sublayer with non-finite position [inf inf]

    Anyone having the same issue and how did you solve it?

    Solutions Collect From Internet About “sublayer with non-finite position”

    Here is how I solved this:

    Following this post

    the error is coming from the library I used, so do a search on all the files and find out


    and change them all to


    That resolved the problem.