iphone - UIView 的 -drawRect 是否为 : have to be called on the main thread?

标签 iphone ios uiview

UIView 的 -drawRect: 方法是否必须在主线程上绘制,或者 CADisplayLink 是否可以在不同的运行循环中在自定义 View 上调用 -setNeedsDisplay

最佳答案

As of iOS 4.0 ,您可以在后台线程上的 UIView 的 -drawRect: 中绘制:

  • Drawing to a graphics context in UIKit is now thread-safe. Specifically:
    • The routines used to access and manipulate the graphics context can now correctly handle contexts residing on different threads.
    • String and image drawing is now thread-safe.
    • Using color and font objects in multiple threads is now safe to do.

另请参阅他们在 Technical Q&A QA1637 中的评论在 iOS 4.0 中对此进行了说明。

在此之前的任何版本的 iOS 仍然需要将此绘图放在主线程上。

关于iphone - UIView 的 -drawRect 是否为 : have to be called on the main thread?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5182686/

相关文章:

ios - 基于 subview 灵活调整UIView大小的固方案

iphone - 性能最高的音频层?

iPhone UIScrollview : Button does not respond when located below 480 pixels on Scroll View's child UIView

iphone - 为什么 NSDateFormatter 无法解析 ISO 8601 格式的日期

ios - 如何通过单击播放按钮而不是嵌入来触发 YouTube 视频在 iOS 上的浏览​​器中播放?

ios - 在计算器中添加负数时出错

ios - 将 UIView 粘贴到屏幕顶部

ios - XCode iPhone 模拟器看起来不像 iPhone

ios - Xcode 8.21 (8C1002) 在 VirtualBox 上处理 iPhone 6s 10.1.1 (14B100) 的符号文件时卡住

ios - Thread 1 : EXC_BAD_ACCESS (code=1, address=0x20) 当subView