我如何拍摄“屏幕截图"?一个 NSView? [英] How do I take a "screenshot" of an NSView?

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

问题描述

我需要将 NSView 的内容放入一个 NSImage 中,用于实验项目.这可能吗?我做了一些谷歌搜索,尝试了两种我发现的方法 - 但它们并没有真正奏效.有什么建议吗?

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天全站免登陆