在mac os中绘制图像

时间:2012-03-04 10:41:45

标签: ios macos core-graphics osx-lion

我需要在mac os项目中绘制一个图像。在iOS中,我可以使用UIGraphicsBeginImageContext执行此操作 请举个例子,如何在mac os中绘制图像或模拟UIGraphicsBeginImageContext api。

1 个答案:

答案 0 :(得分:5)

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

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

// Do your drawing here...

[anImage unlockFocus];

来自Cocoa绘图documentation