What is the equivalent of UIGraphicsGetCurrentContext () for OS X?

The name says it all.

I am trying to understand what is the equivalent of UIGraphicsGetCurrentContext() for OS X.

+9
objective-c swift core-graphics macos
source share
3 answers

[NSGraphicsContext currentContext].CGContext .

(The -CGContext property -CGContext available in 10.10 and later, in earlier versions you can use graphicsPort .)

+14
source share

For Swift: NSGraphicsContext.currentContext()?.CGContext

+3
source share

Just for completeness, in Swift 4 the syntax is:

 NSGraphicsContext.current?.cgContext 
0
source share

All Articles