<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSClipView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSClipView"
  },
  "title" : "NSClipView"
}
-->

# NSClipView

An object that clips a document view to a scroll view’s frame.

```
class NSClipView
```

## Overview

An [`NSClipView`](/documentation/AppKit/NSClipView) holds the document view of an [`NSScrollView`](/documentation/AppKit/NSScrollView), clipping the document view to its frame, handling the details of scrolling in an efficient manner, and updating the [`NSScrollView`](/documentation/AppKit/NSScrollView) when the document view’s size or position changes.

You don’t typically use the [`NSClipView`](/documentation/AppKit/NSClipView) class directly; it’s provided primarily as the scrolling machinery for the [`NSScrollView`](/documentation/AppKit/NSScrollView) class. However, you might use the [`NSClipView`](/documentation/AppKit/NSClipView) class to implement a class similar to [`NSScrollView`](/documentation/AppKit/NSScrollView).

### Interaction with NSScrollView

When using an [`NSClipView`](/documentation/AppKit/NSClipView) within an [`NSScrollView`](/documentation/AppKit/NSScrollView) (the usual configuration), you should access the [`NSScrollView`](/documentation/AppKit/NSScrollView) properties that control background drawing state, rather than accessing these properties of the [`NSClipView`](/documentation/AppKit/NSClipView). This recommendation applies to the following properties:

- [`backgroundColor`](/documentation/AppKit/NSClipView/backgroundColor)
- [`drawsBackground`](/documentation/AppKit/NSClipView/drawsBackground)

The [`NSClipView`](/documentation/AppKit/NSClipView) methods are intended for when the [`NSClipView`](/documentation/AppKit/NSClipView) is used independently of a containing [`NSScrollView`](/documentation/AppKit/NSScrollView). In the usual case, [`NSScrollView`](/documentation/AppKit/NSScrollView) should be allowed to manage the background-drawing properties of its associated [`NSClipView`](/documentation/AppKit/NSClipView).

There is only one background-drawing state per [`NSScrollView`](/documentation/AppKit/NSScrollView)/[`NSClipView`](/documentation/AppKit/NSClipView) pair. The two objects do not maintain independent and distinct [`drawsBackground`](/documentation/AppKit/NSClipView/drawsBackground) and [`backgroundColor`](/documentation/AppKit/NSClipView/backgroundColor) properties; rather, the accessors for these properties on [`NSScrollView`](/documentation/AppKit/NSScrollView) largely defer to the associated [`NSClipView`](/documentation/AppKit/NSClipView) and allow the [`NSClipView`](/documentation/AppKit/NSClipView) to maintain the state. Note that this state is not cached by the [`NSScrollView`](/documentation/AppKit/NSScrollView) object.

It is also important to note that setting [`drawsBackground`](/documentation/AppKit/NSClipView/drawsBackground) to <doc://com.apple.documentation/documentation/Swift/false> in an [`NSScrollView`](/documentation/AppKit/NSScrollView) has the added effect of setting the [`NSClipView`](/documentation/AppKit/NSClipView) property [`copiesOnScroll`](/documentation/AppKit/NSClipView/copiesOnScroll) to <doc://com.apple.documentation/documentation/Swift/false>. The side effect of setting the [`drawsBackground`](/documentation/AppKit/NSClipView/drawsBackground) property directly to the [`NSClipView`](/documentation/AppKit/NSClipView) is the appearance of “trails” (vestiges of previous drawing) in the document view as it is scrolled.

## Topics

### Setting the Document View

[`documentView`](/documentation/AppKit/NSClipView/documentView)

The clip view’s document view.

### Scrolling

[`-  scrollToPoint:`](/documentation/AppKit/NSClipView/scroll(to:))

Changes the origin of the clip view’s bounds rectangle to `newOrigin`.

[`-  autoscroll:`](/documentation/AppKit/NSClipView/autoscroll(with:))

Scrolls the clip view proportionally to `theEvent`’s distance outside of it.

[`-  constrainScrollPoint:`](/documentation/AppKit/NSClipView/constrainScroll(_:))

Returns a scroll point adjusted from the proposed new origin, if necessary, to guarantee the view will lie within its document view.

[`-  constrainBoundsRect:`](/documentation/AppKit/NSClipView/constrainBoundsRect(_:))

Constrains the bounds of the clip view while the user is magnifying and scrolling.

### Determining Scrolling Efficiency

[`copiesOnScroll`](/documentation/AppKit/NSClipView/copiesOnScroll)

A Boolean value that indicates if the clip view copies rendered images while scrolling.

### Accessing the Content Insets

[`contentInsets`](/documentation/AppKit/NSClipView/contentInsets)

The distance that the content view is inset from the enclosing scroll view.

[`automaticallyAdjustsContentInsets`](/documentation/AppKit/NSClipView/automaticallyAdjustsContentInsets)

A Boolean value that indicates if the clip view automatically accounts for other scroll view subviews.

### Accessing the Visible Portion

[`documentRect`](/documentation/AppKit/NSClipView/documentRect)

The rectangle defining the document view’s frame, adjusted to the size of the clip view if the document view is smaller.

[`documentVisibleRect`](/documentation/AppKit/NSClipView/documentVisibleRect)

The exposed rectangle of the clip view’s document view, in the document view’s own coordinate system.

### Setting the Document Cursor

[`documentCursor`](/documentation/AppKit/NSClipView/documentCursor)

The cursor object used when the pointer lies over the view.

### Working with Background Color

[`drawsBackground`](/documentation/AppKit/NSClipView/drawsBackground)

A Boolean value that indicates if the clip view draws its background color.

[`backgroundColor`](/documentation/AppKit/NSClipView/backgroundColor)

The color of the clip view’s background.

### Overriding NSView Methods

[`-  viewBoundsChanged:`](/documentation/AppKit/NSClipView/viewBoundsChanged(_:))

Handles an [`boundsDidChangeNotification`](/documentation/AppKit/NSView/boundsDidChangeNotification), passed in the `aNotification` argument, by updating a containing [`NSScrollView`](/documentation/AppKit/NSScrollView) based on the new bounds.

[`-  viewFrameChanged:`](/documentation/AppKit/NSClipView/viewFrameChanged(_:))

Handles an [`frameDidChangeNotification`](/documentation/AppKit/NSView/frameDidChangeNotification), passed in the `aNotification` argument, by updating a containing [`NSScrollView`](/documentation/AppKit/NSScrollView) based on the new frame.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSAnimatablePropertyContainer`](/documentation/AppKit/NSAnimatablePropertyContainer)

[`Sendable`](/documentation/Swift/Sendable)

[`NSUserActivityRestoring`](/documentation/AppKit/NSUserActivityRestoring)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSStandardKeyBindingResponding`](/documentation/AppKit/NSStandardKeyBindingResponding)

[`NSAppearanceCustomization`](/documentation/AppKit/NSAppearanceCustomization)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`NSDraggingDestination`](/documentation/AppKit/NSDraggingDestination)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

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

---

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)