我想知道什么是 NSWindowGraphicContext 以及如何访问它? 看来是隐藏的。无论如何,当我遵循代码时,className 原来是 NSWindowGraphicContext。
NSGraphicsContext *graphiccontext = [NSGraphicsContext currentContext];
const char* className = class_getName([graphiccontext class]);
与 CGContextRef 相同。
文档说
"A window graphics context is a graphics context that you can use to draw into a window. Note that because Quartz 2D is a graphics engine and not a window management system, you use one of the application frameworks to obtain a graphics context for a window."
但它没有提供标题名称或创建标题的详细信息,就像位图上下文和 PDF 图形上下文那样?我想更多地了解他们。
我认为苹果不想向用户公开这些详细信息。但我需要了解更多。
最佳答案
这是 Apple 使用的私有(private)子类,您不应该知道它。因此,没有公共(public)文档或标题。它将自动为您的窗口创建。您可以通过访问当前上下文(就像您在问题中所做的那样)来获取它,或者像这样:
[NSGraphicsContext graphicsContextWithWindow:theWindow];
如果你想了解更多关于该类的信息,可以运行class-dump在 AppKit 上获取 header 。使用 header 中的信息,您也许能够创建新的上下文,但它们可能很难正确设置,最好向系统询问一个。
关于cocoa - NSWindowGraphicContext?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6295152/