【发布时间】:2013-08-02 11:44:19
【问题描述】:
我有以下方法可以截取太慢的 UIView 的屏幕截图(UIImage)
+ (UIImage *)imageWithView:(UIView *)view
{
CGSize size = view.bounds.size;
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext()
return image;
}
在我的 iPad 上,我现在有一个应用程序需要这种方法来制作拖放视图的副本。这个视图是一个圆角的视图,因此不是不透明的(如果我将 isOpaque 参数设置为 YES 我发现这并没有什么不同)...... 此外,截屏的视图包含一个 UITableView,其中包含相当复杂的条目...
您对我如何提高截屏速度有什么建议吗?现在,对于更大的表格视图(可能 20 个条目)大约需要 1 秒(!!!) 并且视图已经在屏幕上,正确渲染...所以我只需要像素到 UIImageView...
我需要支持 iOS 6+。
【问题讨论】:
标签: ios performance uiimage core-graphics screenshot