UITextView の「スナップショット」を CGImage として取得していますが、問題は UITextView のコンテンツが非常に長く (約 110k contentSize.height )、UITextView レイヤーをコンテキストにレンダリングするとメモリ使用量が増えることです。デバイスで実行するとアプリケーションがクラッシュする原因となる最大 130 MB。
これがコードです。viewref
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();
では、UITextView レイヤーの一部のみを画像コンテキストにレンダリングできますか?