作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一些自定义的、基于 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/
我是一名优秀的程序员,十分优秀!