【发布时间】:2011-10-16 20:17:56
【问题描述】:
我正在尝试获取 UITextView 内容的位图。我可以通过以下方式获取当前屏幕上 UITextView 内容的位图:
UIGraphicsBeginImageContext(myTextView.bounds.size);
[myTextView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
myImageView.image=resultingImage;
UIGraphicsEndImageContext();
但我想要所有内容的位图,而不仅仅是屏幕上可见的内容。这可能吗?请注意,我不仅想要 UITextView 的文本,还想要内容本身的位图。我四处搜索,发现如何在 Android 中使用 getDrawingCache 执行此操作,但找不到目标 c 的任何内容。
【问题讨论】:
-
正是我需要的@Mat 非常感谢!
-
不客气……请注意,如果要渲染一个巨大的 uiview(如长 tableview),则该方法需要很长时间才能执行。
标签: iphone objective-c ios