UIView -drawRect: need to be called in the main thread?

Is it required to use the UIView -drawRect: method in the main thread, or can cause a call to CADisplayLink -setNeedsDisplay on a user view in another run loop?

0
source share
2 answers

All UIKit calls must be made in the main thread.

+2
source

Starting with iOS 4.0 , you can draw inside a UIView -drawRect: in the background thread:

  • Drawing graphical context in UIKit is now thread safe. In particular:
    • The routines used to access and manage the graphics context can now correctly handle contexts located on different threads.
    • The line and drawing pattern are now thread safe.
    • Using color and font objects in multiple threads is now safe.

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

Any version of iOS must still have this drawing in the main thread.

+10
source

Source: https://habr.com/ru/post/903937/


All Articles