setNeedsLayout and setNeedsDisplay

IosAutolayoutSetneedsdisplay

Ios Problem Overview


What is the real difference between UIView methods setNeedsLayout and setNeedsDisplay?

As usual documentation is foggy about this.

Ios Solutions


Solution 1 - Ios

Actually the documentation is pretty clear about this:

  • setNeedsLayout will layout subviews

    > Call this method on your application’s main thread when you want to adjust the layout of a view’s subviews.

  • setNeedsDisplay will call for a redraw of your view (drawRect:, etc).

    > You can use this method or the setNeedsDisplayInRect: to notify the system that your view’s contents need to be redrawn.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDuckView Question on Stackoverflow
Solution 1 - IosJoris KluiversView Answer on Stackoverflow