Importance of drawRect, layoutSubViews, and setNeedsDisplay

What is the importance of the drawRect, layoutSubViews and setNeedsDisplay methods. In what contexts should we use them?

+3
source share
1 answer

As the documentation says,

drawRect: Draws the receiver’s image within the passed-in rectangle. 

Parameters

rect: a rectangle defining the area to limit drawing.

This method is used to draw your UIView inside a specific view rectangle.

  • (voids) setNeedsDisplay

drawRect: . , . , setNeedsDisplay . UIView, , .

, , , UIView . , : , ; - .

.

  • () layoutSubviews

subviews, layoutIfNeeded . .

. , , ,

+2

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


All Articles