I'm getting a "snapshot" of an UITextView as CGImage, but the problem is that the content of the UITextView is very long ( about ~110k contentSize.height ) and when I render the UITextView layer in to the context the memory usage becomes ~130MB which causes the application to crash when run on a device.
Here is the code. viewref
is an instance of UITextView.
UIGraphicsBeginImageContext(self.viewref.contentSize);
CGContextRef ctx = UIGraphicsGetCurrentContext();
//render the text
CALayer *tLayer = self.viewref.layer;
[tLayer renderInContext:ctx];
//get the "snapshot"
CGImageRef imageRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
UIGraphicsEndImageContext();
So, can I render only a partial of the UITextView layer to the image context ?