简体   繁体   English

渲染出现在Window外部的CALayer内容

[英]Rendering a CALayer's contents that Appear outside of Window

So I've got a big CALayer in an NSView that is larger than my window (using Cocoa on Mac OS X ). 所以我在NSView中有一个比我的窗口更大的CALayer (在Mac OS X上使用Cocoa )。

Every time I use renderInContext : the only thing that renders is what's viewable in the window, and nothing outside it. 每次我使用renderInContext :渲染的唯一东西就是在窗口中可以看到的东西,外面没有任何东西。

How can I create a bitmap of something outside my visible Rect and export it as a PNG? 如何创建可见Rect之外的某个位图并将其导出为PNG?

I've looked at a bunch of Core Graphics methods but can't find the answer anywhere:( 我看了一堆Core Graphics方法但无法在任何地方找到答案:(

This turned out to be really easy 事实证明这很容易

myLayer.masksToBounds = false

This removes the mask the main window puts on the CALayer and allows it to be exported, even though you can't see it. 这将删除主窗口放在CALayer上的遮罩,并允许导出它,即使您看不到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM