【问题标题】:How to dump CALayer into CGImageRef?如何将 CALayer 转储到 CGImageRef 中?
【发布时间】:2010-01-09 17:41:13
【问题描述】:

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

【问题讨论】:

    标签: objective-c cocoa core-animation core-graphics


    【解决方案1】:

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

    我已经回答了一个类似的问题here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-24
      相关资源
      最近更新 更多