How do I take a “screenshot” of an NSView?

前端 未结 4 1650
说谎
说谎 2020-12-05 05:36

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

4条回答
  •  半阙折子戏
    2020-12-05 06:14

    let dataOfView = view.dataWithPDFInsideRect(view.bounds)
    let imageOfView = NSImage(data: dataOfView)
    

提交回复
热议问题