Class

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.

Declaration

@interface NSScrollView : NSView

Overview

The NSScrollView class is the central coordinator for AppKit’s scrolling machinery, which is composed of this class, and the NSClipView and NSScroller classes.

When using an 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:

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

+ contentSizeForFrameSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:

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

Determining Component Sizes

contentSize

The size of the scroll view’s content view.

documentVisibleRect

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

Managing Graphics Attributes

backgroundColor

The color of the content view’s background.

drawsBackground

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

borderType

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

documentCursor

The content view’s document cursor.

Managing the Views

contentView

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

documentView

The view the scroll view scrolls within its content view.

- addFloatingSubview:forAxis:

Adds a floating subview to the document view.

Managing Scrollers

horizontalScroller

The scroll view’s horizontal scroller.

hasHorizontalScroller

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

verticalScroller

The scroll view’s vertical scroller.

hasVerticalScroller

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

autohidesScrollers

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

Managing Rulers

rulerViewClass

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

hasHorizontalRuler

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

horizontalRulerView

The scroll view’s horizontal ruler view.

hasVerticalRuler

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

verticalRulerView

The scroll view’s vertical ruler view.

rulersVisible

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

Managing Insets

automaticallyAdjustsContentInsets

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

contentInsets

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

scrollerInsets

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

Scroller Style

scrollerKnobStyle

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

scrollerStyle

The scroller style used by the scroll view.

Setting Scrolling Behavior

lineScroll

The scroll view’s line by line scroll amount.

horizontalLineScroll

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

verticalLineScroll

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

pageScroll

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

horizontalPageScroll

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

verticalPageScroll

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

scrollsDynamically

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

- scrollWheel:

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:

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

Arranging Components

- tile

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

Find Bar Positioning

findBarPosition

The position of the find bar.

Specifying a Document’s Predominant Scrolling Behavior

usesPredominantAxisScrolling

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

Specifying the Scroll View Elasticity

horizontalScrollElasticity

The scroll view’s horizontal scrolling elasticity mode.

verticalScrollElasticity

The scroll view’s vertical scrolling elasticity mode.

Flashing Overlay Scroll Bars

- flashScrollers

Flash the overlay scroll bars.

Zooming the Scroll View

allowsMagnification

Allows the user to magnify the scroll view.

magnification

The amount by which the content is currently scaled.

- magnifyToFitRect:

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

maxMagnification

The maximum value to which the content can be magnified.

minMagnification

The minimum value to which the content can be magnified.

- setMagnification:centeredAtPoint:

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

Deprecated Methods

+ frameSizeForContentSize:hasHorizontalScroller:hasVerticalScroller:borderType:

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

Deprecated
+ contentSizeForFrameSize:hasHorizontalScroller:hasVerticalScroller:borderType:

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

Deprecated

Constants

NSScrollElasticity

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

NSScrollViewFindBarPosition

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

Notifications

NSScrollViewWillStartLiveMagnifyNotification

Posted at the beginning of a magnify gesture.

NSScrollViewDidEndLiveMagnifyNotification

Posted at the end of a magnify gesture.

NSScrollViewWillStartLiveScrollNotification

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

NSScrollViewDidLiveScrollNotification

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

NSScrollViewDidEndLiveScrollNotification

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

Relationships

Inherits From

See Also

Views

NSScroller

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

NSClipView

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