开发者

How to dump CALayer into CGImageRef?

开发者 https://www.devze.com 2022-12-15 18:38 出处:网络
I have some custom, CoreAnimation based UI. I\'d like to implement mouse dragging开发者_StackOverflow中文版 of certain CALayers and I\'d like to stick an image of dragged layer to the cursor. The prob

I have some custom, CoreAnimation based UI. I'd like to implement mouse dragging开发者_StackOverflow中文版 of certain CALayers and I'd like to stick an image of dragged layer to the cursor. The problem is, that I can't get the CALayer (which isn't image/.contents based) into an image of some kind - like CGImageRef or NSImage. Any ideas?


CALayer has a renderInContext: method, which accepts a CGContextRef.
After rendering to the context, you can obtain a CGImageRef by calling CGBitmapContextCreateImage(CGContextRef context).

I already answered a similar question here.

0

精彩评论

暂无评论...
验证码 换一张
取 消