I have an NSView in which i do some custom drawing using NSBezierPaths. Some of the paths are drawn transparent using:
NSGraphicsContext.saveGraphicsState()
NSGraphicsContext.current!.compositingOperation = NSCompositingOperation.clear
// Do the path drawing here
NSGraphicsContext.restoreGraphicsState()
The NSView draws all paths as expected. But when, later, i get the view content, transform it to NSData and save it to a file using code like this..
let pdfData = self.dataWithPDF(inside: bounds)
let pdfNSData = NSData.init(data: pdfData)
pdfNSData.write(toFile: "/Users/aUser/Downloads/image.pdf", atomically: true)
the PDF file is created but in the place of the transparent NSBezierPaths i get paths filled with black color. Is this a Cocoa API problem?
Or am i missing something?
I am using Xcode 9.3 and Apple Swift version 4.1
Thanks in advance!!!