问题
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