【发布时间】:2010-01-09 17:41:13
【问题描述】:
我有一些自定义的、基于 CoreAnimation 的 UI。我想实现某些 CALayers 的鼠标拖动,我想将拖动层的图像粘贴到光标上。问题是,我无法将 CALayer(不是基于图像/.contents 的)放入某种图像中——比如 CGImageRef 或 NSImage。有什么想法吗?
【问题讨论】:
标签: objective-c cocoa core-animation core-graphics
我有一些自定义的、基于 CoreAnimation 的 UI。我想实现某些 CALayers 的鼠标拖动,我想将拖动层的图像粘贴到光标上。问题是,我无法将 CALayer(不是基于图像/.contents 的)放入某种图像中——比如 CGImageRef 或 NSImage。有什么想法吗?
【问题讨论】:
标签: objective-c cocoa core-animation core-graphics
CALayer 有一个renderInContext: 方法,它接受CGContextRef。
渲染到上下文后,可以通过调用CGBitmapContextCreateImage(CGContextRef context)获取CGImageRef。
我已经回答了一个类似的问题here。
【讨论】: