【发布时间】:2015-05-23 13:01:31
【问题描述】:
我正在我的应用程序中尝试截取当前屏幕内容的屏幕截图,其中我的 TilingView(基于 CATiledLayers)显示了许多透明的大平铺图像。 我还在 TilingView 中添加了一些子视图,这些子视图在屏幕截图中神奇地捕捉到了,但是没有捕捉到 TilingView 的底层内容!??
以下代码-sn-ps 拍摄可见屏幕的快照,这似乎适用于基于 NON CATiledLayer 的视图层次结构,但不幸的是不适用于我的设置。即使我通过了 TilingView 的最顶层超级视图(作为实际的 UIViewController.view),我也只能在我的快照中看到 StatusBar、NavigationBar、TilingViews 子视图和 TabBar,但同样看不到 TilingViews 内容。
- (UIImage*)captureView:(UIView *)viewToCapture {
CGRect rect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[viewToCapture.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
有人知道或看到我缺少什么吗?我是否需要通过一些对我来说未知的 CG-API 调用来深入研究与 CG 相关的显示堆栈?提前致谢。
【问题讨论】:
标签: ios screenshot catiledlayer uigraphicscontext