Performance of UIView: removeFromSuperview VS hide

前端 未结 3 1262
梦谈多话
梦谈多话 2020-12-28 15:29

This question is really basic. What is the performance difference between removing a UIView from the view hierarchy and hiding a UIView?

I

3条回答
  •  渐次进展
    2020-12-28 16:08

    Some years have passed between the initial question and the (rightfully) accepted answer. Let me add another factor: In the meantime, Apple has introduced AutoLayout, which — as some say — might come with quite a performance penalty in certain (deep) subview hierarchies.

    If you are using AutoLayout, a view that is hidden will still get layouted, as opposed to the removed view (with its reference saved somewhere). Depending on your scenario, this could then make a performance difference.

提交回复
热议问题