标题说明了一切。
我试图弄清楚OS X的UIGraphicsGetCurrentContext()
等价物是什么。
答案 0 :(得分:18)
[NSGraphicsContext currentContext].CGContext
(-CGContext
属性在10.10及更高版本中可用;在早期版本中,您可以使用graphicsPort
。)
答案 1 :(得分:3)
对于Swift:
NSGraphicsContext.currentContext()?.CGContext
答案 2 :(得分:1)
出于完整性考虑,在Swift 4中,语法为:
NSGraphicsContext.current?.cgContext