Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the UIGraphicsGetCurrentContext() equivalent for OS X?

Title says it all.

I'm trying to figure out what the UIGraphicsGetCurrentContext() equivalent is for OS X.

like image 283
CraftMcMatt Avatar asked Aug 26 '15 18:08

CraftMcMatt


3 Answers

Just for completeness, in Swift 4, the syntax is:

NSGraphicsContext.current?.cgContext
like image 62
koen Avatar answered Sep 28 '22 10:09

koen


[NSGraphicsContext currentContext].CGContext.

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

like image 20
jtbandes Avatar answered Nov 05 '22 04:11

jtbandes


For Swift: NSGraphicsContext.currentContext()?.CGContext

like image 4
SammyRNYCreal Avatar answered Nov 05 '22 06:11

SammyRNYCreal