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.
我尝试在 drawRect 以外的其他地方调用 UIGraphicsGetCurrentContext()。它给了我一个NULL。我只能在 UIView 的 drawRect: 中获取当前上下文是真的吗?
是的,在 drawRect 之外,默认上下文是 nil。在调用 drawRect 之前,视图会将其上下文压入堆栈,并在 drawRect 结束后将其弹出。