gpt4 book ai didi

objective-c - 如何将 CALayer 转储到 CGImageRef 中?

转载 作者:太空狗 更新时间:2023-10-30 03:26:25 24 4
gpt4 key购买 nike

我有一些自定义的、基于 CoreAnimation 的 UI。我想实现某些 CALayers 的鼠标拖动,我想将拖动图层的图像粘贴到光标上。问题是,我无法将 CALayer(不是基于 image/.contents 的)放入某种图像中——比如 CGImageRef 或 NSImage。有什么想法吗?

最佳答案

CALayer 有一个 renderInContext:方法,它接受一个 CGContextRef
渲染到上下文后,您可以通过调用 CGBitmapContextCreateImage(CGContextRef context) 获得一个 CGImageRef

我已经回答过类似的问题here .

关于objective-c - 如何将 CALayer 转储到 CGImageRef 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2034261/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com