Informs the view that it will be required to draw content.
In response to receiving one of the display methods, the view will recurse down the view hierarchy, sending this message to each of the views that may be involved in the display operation.
Subclasses can override this method to move or resize views, mark additional areas as requiring display, or other actions that can best be deferred until they are required for drawing. During the recursion, setting the needsDisplay property or sending the setNeedsDisplay(_:) message to views in the hierarchy that are about to be drawn is valid and supported, and will affect the assessment of the total area to be rendered in that drawing pass.
A subclass’s implementation of viewWillDraw can use the existing NSView getRectsBeingDrawn(_:count:) method to obtain a list of rectangles that bound the affected area, enabling it to restrict its efforts to that area.
The following is an example of a generic subclass implementation: