Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在追踪 drawInRect 的确切用法时遇到了一些麻烦;我知道语法,但它只能在 UIView 或其子类中使用吗?所需的“上下文”到底是什么,以及如何创建或获取它?
上下文就像核心图形绘制的画布。UIGraphicsGetCurrentContext()您可以通过调用 inside从任何 UIView 获取上下文drawRect:。您还可以在任何地方创建自己的上下文,您可以从中创建 UIImage 或保存到文件等。
UIGraphicsGetCurrentContext()
drawRect:
希望这可以帮助!