<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/nsview-drawing",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Drawing"
}
-->

# Drawing

Draw the content of custom views and update that content when the view’s size or appearance changes.

## Topics

### Drawing the View’s Content

[`func updateLayer()`](/documentation/AppKit/NSView/updateLayer())

Updates the view’s content by modifying its underlying layer.

[`func draw(NSRect)`](/documentation/AppKit/NSView/draw(_:))

Overridden by subclasses to draw the view’s image within the specified rectangle.

[`var clipsToBounds: Bool`](/documentation/AppKit/NSView/clipsToBounds)

A Boolean value that indicates whether the view, and its subviews, confine their drawing areas to the bounds of the view.

[`var canDrawConcurrently: Bool`](/documentation/AppKit/NSView/canDrawConcurrently)

A Boolean value indicating whether the view can draw its contents on a background thread.

[`var visibleRect: NSRect`](/documentation/AppKit/NSView/visibleRect)

The portion of the view that isn’t clipped by its superviews.

[`func getRectsBeingDrawn(UnsafeMutablePointer<UnsafePointer<NSRect>?>?, count: UnsafeMutablePointer<Int>?)`](/documentation/AppKit/NSView/getRectsBeingDrawn(_:count:))

Returns by indirection a list of nonoverlapping rectangles that define the area the view is being asked to draw in [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)).

[`func needsToDraw(NSRect) -> Bool`](/documentation/AppKit/NSView/needsToDraw(_:))

Returns a Boolean value indicating whether the specified rectangle intersects any part of the area that the view is being asked to draw.

[`var wantsDefaultClipping: Bool`](/documentation/AppKit/NSView/wantsDefaultClipping)

A Boolean value indicating whether AppKit’s default clipping behavior is in effect.

[`func bitmapImageRepForCachingDisplay(in: NSRect) -> NSBitmapImageRep?`](/documentation/AppKit/NSView/bitmapImageRepForCachingDisplay(in:))

Returns a bitmap-representation object suitable for caching the specified portion of the view.

[`func cacheDisplay(in: NSRect, to: NSBitmapImageRep)`](/documentation/AppKit/NSView/cacheDisplay(in:to:))

Draws the specified area of the view, and its descendants, into a provided bitmap-representation object.

[`enum NSBorderType`](/documentation/AppKit/NSBorderType)

These constants specify the type of a view’s border.

### Drawing the View in Fullscreen Mode

[`func enterFullScreenMode(NSScreen, withOptions: [NSView.FullScreenModeOptionKey : Any]?) -> Bool`](/documentation/AppKit/NSView/enterFullScreenMode(_:withOptions:))

Sets the view to full screen mode.

[`func exitFullScreenMode(options: [NSView.FullScreenModeOptionKey : Any]?)`](/documentation/AppKit/NSView/exitFullScreenMode(options:))

Instructs the view to exit full screen mode.

[`var isInFullScreenMode: Bool`](/documentation/AppKit/NSView/isInFullScreenMode)

A Boolean value indicating whether the view is in full screen mode.

[`struct FullScreenModeOptionKey`](/documentation/AppKit/NSView/FullScreenModeOptionKey)

These constants are keys that you can use in the options dictionary in [`enterFullScreenMode(_:withOptions:)`](/documentation/AppKit/NSView/enterFullScreenMode(_:withOptions:)) and [`exitFullScreenMode(options:)`](/documentation/AppKit/NSView/exitFullScreenMode(options:)).

### Invalidating the View’s Content

[`func setNeedsDisplay(NSRect)`](/documentation/AppKit/NSView/setNeedsDisplay(_:))

Marks the region of the view within the specified rectangle as needing display, increasing the view’s existing invalid region to include it.

[`var needsDisplay: Bool`](/documentation/AppKit/NSView/needsDisplay)

A Boolean value that determines whether the view needs to be redrawn before being displayed.

[`func display()`](/documentation/AppKit/NSView/display())

Displays the view and all its subviews if possible, invoking each of the `NSView` methods [`lockFocus()`](/documentation/AppKit/NSView/lockFocus()), [`draw(_:)`](/documentation/AppKit/NSView/draw(_:)), and [`unlockFocus()`](/documentation/AppKit/NSView/unlockFocus()) as necessary.

[`func display(NSRect)`](/documentation/AppKit/NSView/display(_:))

Acts as [`display()`](/documentation/AppKit/NSView/display()), but confining drawing to a rectangular region of the view.

[`func displayIgnoringOpacity(NSRect)`](/documentation/AppKit/NSView/displayIgnoringOpacity(_:))

Displays the view but confines drawing to a specified region and does not back up to the first opaque ancestor—it simply causes the view and its descendants to execute their drawing code.

[`func displayIgnoringOpacity(NSRect, in: NSGraphicsContext)`](/documentation/AppKit/NSView/displayIgnoringOpacity(_:in:))

Causes the view and its descendants to be redrawn to the specified graphics context.

[`func displayIfNeeded()`](/documentation/AppKit/NSView/displayIfNeeded())

Displays the view and all its subviews if any part of the view has been marked as needing display.

[`func displayIfNeeded(NSRect)`](/documentation/AppKit/NSView/displayIfNeeded(_:))

Acts as [`displayIfNeeded()`](/documentation/AppKit/NSView/displayIfNeeded()), confining drawing to a specified region of the view.

[`func displayIfNeededIgnoringOpacity()`](/documentation/AppKit/NSView/displayIfNeededIgnoringOpacity())

Acts as [`displayIfNeeded()`](/documentation/AppKit/NSView/displayIfNeeded()), except that this method doesn’t back up to the first opaque ancestor—it simply causes the view and its descendants to execute their drawing code.

[`func displayIfNeededIgnoringOpacity(NSRect)`](/documentation/AppKit/NSView/displayIfNeededIgnoringOpacity(_:))

Acts as [`displayIfNeeded()`](/documentation/AppKit/NSView/displayIfNeeded()), but confining drawing to `aRect` and not backing up to the first opaque ancestor—it simply causes the view and its descendants to execute their drawing code.

[`func translateRectsNeedingDisplay(in: NSRect, by: NSSize)`](/documentation/AppKit/NSView/translateRectsNeedingDisplay(in:by:))

Translates the display rectangles by the specified delta.

[`var isOpaque: Bool`](/documentation/AppKit/NSView/isOpaque)

A Boolean value indicating whether the view fills its frame rectangle with opaque content.

[`func viewWillDraw()`](/documentation/AppKit/NSView/viewWillDraw())

Informs the view that it’s required to draw content.

### Updating the View When Property Values Change

[`struct Invalidating`](/documentation/AppKit/NSView/Invalidating)

A property wrapper that notifies the system that a property value change has invalidated an aspect of the containing view.

[`protocol NSViewInvalidating`](/documentation/AppKit/NSViewInvalidating)

Implements a type of invalidation that can occur on a view that requires an update.

### Managing Live Resize

[`var inLiveResize: Bool`](/documentation/AppKit/NSView/inLiveResize)

A Boolean value indicating whether the view is being rendered as part of a live resizing operation.

[`var preservesContentDuringLiveResize: Bool`](/documentation/AppKit/NSView/preservesContentDuringLiveResize)

A Boolean value indicating whether the view optimizes live-resize operations by preserving content that has not moved.

[`func getRectsExposedDuringLiveResize(UnsafeMutablePointer<NSRect>, count: UnsafeMutablePointer<Int>)`](/documentation/AppKit/NSView/getRectsExposedDuringLiveResize(_:count:))

Returns a list of rectangles indicating the newly exposed areas of the view.

[`var rectPreservedDuringLiveResize: NSRect`](/documentation/AppKit/NSView/rectPreservedDuringLiveResize)

The rectangle identifying the portion of your view that did not change during a live resize operation.

[`func viewWillStartLiveResize()`](/documentation/AppKit/NSView/viewWillStartLiveResize())

Informs the view of the start of a live resize—the user has started resizing the view.

[`func viewDidEndLiveResize()`](/documentation/AppKit/NSView/viewDidEndLiveResize())

Informs the view of the end of a live resize—the user has finished resizing the view.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)