在mac os中绘制图像

row*_*man 1 macos core-graphics ios osx-lion

我需要在mac os项目中绘制一个图像.在iOS中,我可以使用UIGraphicsBeginImageContext.
请举个例子,如何在mac os中绘制图像或者给出UIGraphicsBeginImageContextapi 的模拟.

Flu*_*imp 5

如果你想要绘制一个NSImage,你会想要:

NSImage* anImage = [[NSImage alloc] initWithSize:NSMakeSize(100.0,  100.0)];
[anImage lockFocus];

// Do your drawing here...

[anImage unlockFocus];
Run Code Online (Sandbox Code Playgroud)

来自Cocoa绘图文档.