如何获取“屏幕截图”的NSView? [英] How do I take a "screenshot" of an NSView?

查看:197
本文介绍了如何获取“屏幕截图”的NSView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个 NSView 的内容,并将它们放在一个实验项目的 NSImage 中。这可能吗?我做了一些Googling,尝试了两种方法,我发现 - 但他们没有真正工作。任何建议?

I need to take the contents of an NSView and put them in an NSImage, for an experimental project. Is this possible? I did some Googling, tried two methods that I found - but they didn't really work. Any suggestions?

推荐答案

[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];

这篇关于如何获取“屏幕截图”的NSView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆