0

Does UIView's -drawRect: method have to be drawn on the main thread or can CADisplayLink call -setNeedsDisplay on a custom view in a different run loop?

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
dubbeat
  • 7,706
  • 18
  • 70
  • 122

2 Answers2

10

As of iOS 4.0, you can draw within a UIView's -drawRect: on a background thread:

  • 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.

See also their comments in Technical Q&A QA1637 regarding this in iOS 4.0.

Any version of iOS before that still needs to have this drawing be on the main thread.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
2

All UIKit calls should be done on the main thread.

Jeff Kelley
  • 19,021
  • 6
  • 70
  • 80