Is it ok to create a UIView on a background thread?

前端 未结 3 721
长发绾君心
长发绾君心 2020-12-03 07:42

I know UIView are not thread safe so i cant add a view on a background thread, to work around this is it ok to create a UIView on a background thread then add it on the main

3条回答
  •  生来不讨喜
    2020-12-03 08:17

    The Drawing and Printing Guide states:

    Important The UIKit classes are generally not thread safe. All drawing-related operations should be performed on your application’s main thread.

    Thus, as I understand this, it seems that the only problem is related to "drawing-related operations". If we assume that a correct class only execute such operation in its drawRect: method, then the approach you suggest should be fine.

提交回复
热议问题