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

# NSScrollView

A view that displays a portion of a document view and provides scroll bars that allow the user to move the document view within the scroll view.

```
class NSScrollView
```

## Overview

The [`NSScrollView`](/documentation/AppKit/NSScrollView) class is the central coordinator for AppKit’s scrolling machinery, which is composed of this class, and the [`NSClipView`](/documentation/AppKit/NSClipView) and [`NSScroller`](/documentation/AppKit/NSScroller) classes.

When using an [`NSClipView`](/documentation/AppKit/NSClipView) object within a scroll view (the usual configuration), you should issue messages that control background drawing state to the scroll view directly, rather than messaging the clip view.

## Topics

### Calculating Layout

[`+  frameSizeForContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:`](/documentation/AppKit/NSScrollView/frameSize(forContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:))

Returns the frame size of a scroll view that contains a content view with the specified size.

[`+  contentSizeForFrameSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:`](/documentation/AppKit/NSScrollView/contentSize(forFrameSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:))

Returns the content size calculated from the frame size and the specified specifications.

### Determining Component Sizes

[`contentSize`](/documentation/AppKit/NSScrollView/contentSize)

The size of the scroll view’s content view.

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

The portion of the document view, in its own coordinate system, visible through the scroll view’s content view.

### Managing Graphics Attributes

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

The color of the content view’s background.

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

A Boolean that indicates whether the scroll view draws its background.

[`borderType`](/documentation/AppKit/NSScrollView/borderType)

A value that specifies the appearance of the scroll view’s border.

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

The content view’s document cursor.

### Managing the Views

[`contentView`](/documentation/AppKit/NSScrollView/contentView)

The scroll view’s content view, the view that clips the document view.

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

The view the scroll view scrolls within its content view.

[`-  addFloatingSubview:forAxis:`](/documentation/AppKit/NSScrollView/addFloatingSubview(_:for:))

Adds a floating subview to the document view.

### Managing Scrollers

[`horizontalScroller`](/documentation/AppKit/NSScrollView/horizontalScroller)

The scroll view’s horizontal scroller.

[`hasHorizontalScroller`](/documentation/AppKit/NSScrollView/hasHorizontalScroller)

A Boolean that indicates whether the scroll view has a horizontal scroller.

[`verticalScroller`](/documentation/AppKit/NSScrollView/verticalScroller)

The scroll view’s vertical scroller.

[`hasVerticalScroller`](/documentation/AppKit/NSScrollView/hasVerticalScroller)

A Boolean that indicates whether the scroll view has a vertical scroller.

[`autohidesScrollers`](/documentation/AppKit/NSScrollView/autohidesScrollers)

A Boolean that indicates whether the scroll view automatically hides its scroll bars when they are not needed.

### Managing Rulers

[`rulerViewClass`](/documentation/AppKit/NSScrollView/rulerViewClass)

Returns the default class to be used for ruler objects in NSScrollViews.

[`hasHorizontalRuler`](/documentation/AppKit/NSScrollView/hasHorizontalRuler)

A Boolean that indicates whether the scroll view keeps a horizontal ruler object.

[`horizontalRulerView`](/documentation/AppKit/NSScrollView/horizontalRulerView)

The scroll view’s horizontal ruler view.

[`hasVerticalRuler`](/documentation/AppKit/NSScrollView/hasVerticalRuler)

A Boolean that indicates whether the scroll view keeps a vertical ruler object.

[`verticalRulerView`](/documentation/AppKit/NSScrollView/verticalRulerView)

The scroll view’s vertical ruler view.

[`rulersVisible`](/documentation/AppKit/NSScrollView/rulersVisible)

A Boolean that indicates whether the scroll view displays its rulers.

### Managing Insets

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

A Boolean that indicates whether the scroll view automatically adjusts its content insets.

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

The distance that the scroll view’s subviews are inset from the enclosing scroll view during tiling.

[`scrollerInsets`](/documentation/AppKit/NSScrollView/scrollerInsets)

The distance the scrollers are inset from the edge of the scroll view.

### Scroller Style

[`scrollerKnobStyle`](/documentation/AppKit/NSScrollView/scrollerKnobStyle)

The knob style of scroll views that use the overlay scroller style.

[`scrollerStyle`](/documentation/AppKit/NSScrollView/scrollerStyle)

The scroller style used by the scroll view.

### Setting Scrolling Behavior

[`lineScroll`](/documentation/AppKit/NSScrollView/lineScroll)

The scroll view’s line by line scroll amount.

[`horizontalLineScroll`](/documentation/AppKit/NSScrollView/horizontalLineScroll)

The scroll view’s horizontal line by line scroll amount.

[`verticalLineScroll`](/documentation/AppKit/NSScrollView/verticalLineScroll)

The scroll view’s vertical line by line scroll amount.

[`pageScroll`](/documentation/AppKit/NSScrollView/pageScroll)

The amount of the document view kept visible when scrolling page by page.

[`horizontalPageScroll`](/documentation/AppKit/NSScrollView/horizontalPageScroll)

The amount of the document view kept visible when scrolling horizontally page by page.

[`verticalPageScroll`](/documentation/AppKit/NSScrollView/verticalPageScroll)

The amount of the document view kept visible when scrolling vertically page by page.

[`scrollsDynamically`](/documentation/AppKit/NSScrollView/scrollsDynamically)

A Boolean that indicates whether the scroll view redraws its document view while scrolling continuously.

[`-  scrollWheel:`](/documentation/AppKit/NSScrollView/scrollWheel(with:))

Scrolls the receiver up or down, in response to the user moving the mouse’s scroll wheel specified by `theEvent`.

### Updating Display After Scrolling

[`-  reflectScrolledClipView:`](/documentation/AppKit/NSScrollView/reflectScrolledClipView(_:))

Adjusts the receiver’s scrollers to reflect the size and positioning of its content view.

### Arranging Components

[`-  tile`](/documentation/AppKit/NSScrollView/tile())

Lays out the components of the receiver: the content view, the scrollers, and the ruler views.

### Find Bar Positioning

[`findBarPosition`](/documentation/AppKit/NSScrollView/findBarPosition-swift.property)

The position of the find bar.

### Specifying a Document’s Predominant Scrolling Behavior

[`usesPredominantAxisScrolling`](/documentation/AppKit/NSScrollView/usesPredominantAxisScrolling)

A Boolean that indicates whether the scroll view uses a predominant scrolling axis for content.

### Specifying the Scroll View Elasticity

[`horizontalScrollElasticity`](/documentation/AppKit/NSScrollView/horizontalScrollElasticity)

The scroll view’s horizontal scrolling elasticity mode.

[`verticalScrollElasticity`](/documentation/AppKit/NSScrollView/verticalScrollElasticity)

The scroll view’s vertical scrolling elasticity mode.

### Flashing Overlay Scroll Bars

[`-  flashScrollers`](/documentation/AppKit/NSScrollView/flashScrollers())

Flash the overlay scroll bars.

### Zooming the Scroll View

[`allowsMagnification`](/documentation/AppKit/NSScrollView/allowsMagnification)

Allows the user to magnify the scroll view.

[`magnification`](/documentation/AppKit/NSScrollView/magnification)

The amount by which the content is currently scaled.

[`-  magnifyToFitRect:`](/documentation/AppKit/NSScrollView/magnify(toFit:))

Magnifies the content view proportionally such that the given rectangle fits centered in the scroll view.

[`maxMagnification`](/documentation/AppKit/NSScrollView/maxMagnification)

The maximum value to which the content can be magnified.

[`minMagnification`](/documentation/AppKit/NSScrollView/minMagnification)

The minimum value to which the content can be magnified.

[`-  setMagnification:centeredAtPoint:`](/documentation/AppKit/NSScrollView/setMagnification(_:centeredAt:))

Magnify the content by the given amount and center the result on the given point.

### Deprecated Methods

[`+  frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType:`](/documentation/AppKit/NSScrollView/frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType:)

Returns the frame size of an scroll view that contains a content view with the specified size.

[`+  contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType:`](/documentation/AppKit/NSScrollView/contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType:)

Returns the content size calculated from the frame size and the specified specifications.

### Constants

[`Elasticity`](/documentation/AppKit/NSScrollView/Elasticity)

These constants determine the elasticity behavior for an axis of the scrollview.

[`FindBarPosition`](/documentation/AppKit/NSScrollView/FindBarPosition-swift.enum)

These constants define the position of the find bar in relation to the scroll view.

### Notifications

[`NSScrollViewWillStartLiveMagnifyNotification`](/documentation/AppKit/NSScrollView/willStartLiveMagnifyNotification)

Posted at the beginning of a magnify gesture.

[`NSScrollViewDidEndLiveMagnifyNotification`](/documentation/AppKit/NSScrollView/didEndLiveMagnifyNotification)

Posted at the end of a magnify gesture.

[`NSScrollViewWillStartLiveScrollNotification`](/documentation/AppKit/NSScrollView/willStartLiveScrollNotification)

Posted on the main thread at the beginning of user-initiated live scroll tracking (gesture scroll or scroller tracking, for example, thumb dragging).

[`NSScrollViewDidLiveScrollNotification`](/documentation/AppKit/NSScrollView/didLiveScrollNotification)

Posted on the main thread after changing the clipview bounds origin due to a user-initiated event.

[`NSScrollViewDidEndLiveScrollNotification`](/documentation/AppKit/NSScrollView/didEndLiveScrollNotification)

Posted on the main thread at the end of live scroll tracking.

### Initializers

[`-  initWithCoder:`](/documentation/AppKit/NSScrollView/init(coder:))

[`-  initWithFrame:`](/documentation/AppKit/NSScrollView/init(frame:))

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### 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)