1

在我的 iOS 应用程序中,我在 myview.layer 中添加了 AVPlayerLayer 作为子层。对于我的要求,我必须截取这个特定视图的屏幕截图。如果我截取此特定视图的屏幕截图,则屏幕截图中不包含图层部分。而且我在 Xcode 预览选项中的 myview 中也看不到这一层。请任何人提出您的建议以完成此问题。

ps:本参考资料中的所有方法我都试过了。

但是所有这些方法都排除了这个 CALayer。

编辑内容:

我需要包含层(AVPlayerLayer)的 UIView 的屏幕截图。有很多选项可以截取 UIView 的屏幕截图。但是这些选项都没有帮助我。所以我发布了这个问题来解决我的问题。

4

1 回答 1

0

Tim的这个解决方案应该可以完美运行(为方便起见,复制如下)。

#import "QuartzCore/QuartzCore.h" after you added the framework to your project. Then do:

UIGraphicsBeginImageContext(yourView.frame.size);
[[yourView layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// The result is *screenshot
于 2015-05-11T03:09:19.290 回答