When do I need to call setNeedsDisplay in iOS?

后端 未结 5 742
执念已碎
执念已碎 2020-11-30 18:49

When creating an iOS app, I\'m confused as to when exactly I need to call setNeedsDisplay? I know that it has something to do with updating/redrawing the UI; h

5条回答
  •  余生分开走
    2020-11-30 19:12

    I think @Amogh Talpallikar make it clear. And I just wanna discuss one thing more.

    In the fact that, you should avoid override drawRectunless you really need it because it can cause bad performance. You can refer this https://yalantis.com/blog/mastering-uikit-performance/

    If you only wanna change frame, position of buttons, labels, ... you can call setNeedLayout or layoutIfNeeded

提交回复
热议问题