苹果文档指出,一般来说 Quartz2D 是 thread-safe 。然而,当在 NSOperation 期间绘制到图像上下文时,我遇到了崩溃(EXC_BAD_ACCESS)。
这是我当前的设置:
UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing code
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
我怀疑崩溃与当前上下文有关,因为 UIGraphicsGetCurrentContext 文档指出需要从 main thread 调用它。 。它是否正确?还有其他方法获取图像上下文吗?
最佳答案
各种 UIGraphics 函数大多只是围绕较低级别函数的便捷方法。阅读 CGGraphicsContext 以及如何创建您自己的;该文档非常有帮助。
关于iphone - iPhone 上的线程绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1516944/