How to print an NSOutlineView with NSVIew.printView

烂漫一生 提交于 2021-02-17 06:46:06

问题


I want to print an NSOutlineView. The view is a subview of a window on screen. I noticed the NSView api call printView. So I tried it in a simple minded fashion. In my AppDelegate I have a call:

@IBAction func doPrint(_ sender: Any?) {
    globalOutlineCntrl?.outlineView.printView(self)
}

So with the window containing the outline on-screen, I issued the doPrint call.

The outline on screen looks like this: The doPrint call seems to work, but prints this: Is there anyway to make this work? If not how else to print a subview outline?


回答1:


Dark mode causes some issues with printing. The easiest workaround is to create a separate, programmatic view with forced light appearance, clone the required content and then print that view.

view.appearance = NSAppearance(named: .aqua)



来源:https://stackoverflow.com/questions/66040103/how-to-print-an-nsoutlineview-with-nsview-printview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!