Overridden by subclasses to draw the view’s image within the specified rectangle.
- macOS 10.0+
A rectangle defining the portion of the view that requires redrawing. This rectangle usually represents the portion of the view that requires updating. When responsive scrolling is enabled, this rectangle can also represent a nonvisible portion of the view that AppKit wants to cache.
Use this method to draw the specified portion of your view’s content. Your implementation of this method should be as fast as possible and do as little work as possible. The
dirty parameter helps you achieve better performance by specifying the portion of the view that needs to be drawn. You should always limit drawing to the content inside this rectangle. For even better performance, you can call the
get method and use the list of rectangles returned by that method to limit drawing even further. You can also use the
needs method test whether objects in a particular rectangle need to be drawn.
The default implementation does nothing. Subclasses should override this method if they do custom drawing. Prior to calling this method, AppKit creates an appropriate drawing context and configures it for drawing to the view; you do not need to configure the drawing context yourself. If your app manages content using its layer object instead, use the
update method to update your layer instead of overriding this method.
If your custom view is a direct
NSView subclass, you do not need to call
super. For all other views, call
super at some point in your implementation so that the parent class can perform any additional drawing.
For information about how to draw in your app, see Cocoa Drawing Guide.