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

# NSScroller

An object that controls scrolling of a document view within a scroll view or other type of container view.

```
class NSScroller
```

## Overview

A scroller displays a slot containing a knob that the user can drag directly to the desired location. The knob indicates both the position within the document view and—by varying in size within the slot—the amount visible relative to the size of the document view.

Typically, you don’t need to program with scrollers; instead, you configure them with an [`NSScrollView`](/documentation/AppKit/NSScrollView) object in a [Nib file](https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/NibFile.html#//apple_ref/doc/uid/TP40008195-CH34).

Don’t use an scroller when a slider would be more appropriate. An [`NSSlider`](/documentation/AppKit/NSSlider) object represents a range of values for something in the application and lets the user choose a setting. A scroller represents the relative position of the visible portion of a view and lets the user choose which portion to view.

## Topics

### Determining Scroller Size

[`scrollerWidth(for:scrollerStyle:)`](/documentation/AppKit/NSScroller/scrollerWidth(for:scrollerStyle:))

Returns the width for scrollers of the receiving class for a given control size and scroller style.

[`scrollerWidth`](/documentation/AppKit/NSScroller/scrollerWidth)

Returns the width for scrollers of the receiving class, assuming a control size [`NSRegularControlSize`](/documentation/AppKit/NSRegularControlSize), and a scroller style of [`NSScroller.Style.legacy`](/documentation/AppKit/NSScroller/Style/legacy).

[`scrollerWidthForControlSize:`](/documentation/AppKit/NSScroller/scrollerWidthForControlSize:)

Returns the width of the scroller based on `controlSize` and assuming a scroller style of [`NSScroller.Style.legacy`](/documentation/AppKit/NSScroller/Style/legacy).

[`controlSize`](/documentation/AppKit/NSScroller/controlSize)

The size of the scroller.

### Laying out a Scroller

[`arrowsPosition`](/documentation/AppKit/NSScroller/arrowsPosition)

The location of the scroll buttons within the scroller, as described in [`NSScroller.ArrowPosition`](/documentation/AppKit/NSScroller/ArrowPosition).

### Setting the Knob Position

[`setFloatValue:knobProportion:`](/documentation/AppKit/NSScroller/setFloatValue:knobProportion:)

Sets the position of the knob to `aFloat`, which is a value from 0.0 (indicating the top or left end) to 1.0 (the bottom or right end).

[`knobProportion`](/documentation/AppKit/NSScroller/knobProportion)

The proportion of the knob slot that the knob should fill.

### Calculating Layout

[`rect(for:)`](/documentation/AppKit/NSScroller/rect(for:))

Returns the rectangle occupied by `aPart`, which for this method is interpreted literally rather than as an indicator of scrolling direction.

[`testPart(_:)`](/documentation/AppKit/NSScroller/testPart(_:))

Returns the part that would be hit by a mouse-down event at `aPoint` (expressed in the window’s coordinate system).

[`checkSpaceForParts()`](/documentation/AppKit/NSScroller/checkSpaceForParts())

Checks to see if there is enough room in the receiver to display the knob and buttons.

[`usableParts`](/documentation/AppKit/NSScroller/usableParts-swift.property)

A value that indicates which parts of the receiver are displayed and usable.

### Drawing Scroller Parts

[`drawArrow(_:highlight:)`](/documentation/AppKit/NSScroller/drawArrow(_:highlight:))

Draws the scroll button indicated by `arrow`, which is either `NSScrollerIncrementArrow` (the down or right scroll button) or `NSScrollerDecrementArrow` (up or left).

[`drawKnobSlot(in:highlight:)`](/documentation/AppKit/NSScroller/drawKnobSlot(in:highlight:))

Draws the portion of the scroller’s track, possibly including the line increment and decrement arrow buttons, that falls in the given rectangle.

[`drawKnob()`](/documentation/AppKit/NSScroller/drawKnob())

Draws the knob.

[`drawParts`](/documentation/AppKit/NSScroller/drawParts)

Caches images for the scroll buttons and knob.

[`highlight(_:)`](/documentation/AppKit/NSScroller/highlight(_:))

Highlights or unhighlights the scroll button the user clicked.

### Event Handling

[`hitPart`](/documentation/AppKit/NSScroller/hitPart)

A part code indicating the manner in which the scrolling should be performed.

[`trackKnob(with:)`](/documentation/AppKit/NSScroller/trackKnob(with:))

Tracks the knob and sends action messages to the receiver’s target.

[`trackScrollButtons(with:)`](/documentation/AppKit/NSScroller/trackScrollButtons(with:))

Tracks the scroll buttons and sends action messages to the receiver’s target.

### Setting Control Tint

[`controlTint`](/documentation/AppKit/NSScroller/controlTint)

The scroller’s control tint.

### Managing Presentation Style

[`preferredScrollerStyle`](/documentation/AppKit/NSScroller/preferredScrollerStyle)

Returns the style of scrollers that applications should use wherever possible.

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

The scroller style for this scroller.

[`knobStyle`](/documentation/AppKit/NSScroller/knobStyle-swift.property)

The scroller’s knob style.

### Constants

[`NSScroller.Style`](/documentation/AppKit/NSScroller/Style)

Constants to specify the scroller style.

[`NSScroller.KnobStyle`](/documentation/AppKit/NSScroller/KnobStyle-swift.enum)

Specify different knob styles.

[`NSScroller.Part`](/documentation/AppKit/NSScroller/Part)

These constants specify the different parts of the scroller:

[`NSScroller.Arrow`](/documentation/AppKit/NSScroller/Arrow)

These constants describe the two scroller buttons and are used by [`drawArrow(_:highlight:)`](/documentation/AppKit/NSScroller/drawArrow(_:highlight:)).

[`NSScroller.ArrowPosition`](/documentation/AppKit/NSScroller/ArrowPosition)

These constants specify where the scroller’s buttons appear and are used by the [`arrowsPosition`](/documentation/AppKit/NSScroller/arrowsPosition) property.

[`NSScroller.UsableParts`](/documentation/AppKit/NSScroller/UsableParts-swift.enum)

These constants specify which parts of the scroller are visible.

### Notifications

[`preferredScrollerStyleDidChangeNotification`](/documentation/AppKit/NSScroller/preferredScrollerStyleDidChangeNotification)

Posted if the preferred scroller style changes.

### Instance Properties

[`knobProportion`](/documentation/AppKit/NSScroller/knobProportion)

The proportion of the knob slot that the knob should fill.

### Type Properties

[`isCompatibleWithOverlayScrollers`](/documentation/AppKit/NSScroller/isCompatibleWithOverlayScrollers)



---

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)