Class

NSScrollView

The NSScrollView class is the central coordinator for the Application Kit’s scrolling machinery, composed of this class, and the NSClipView, and NSScroller classes. A scroll view displays a portion of a document view that’s too large to be displayed whole and provides scroll bars that allow the user to move the document view within the scroll view.

Overview

Note that, when using an NSClipView object within an 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.

Symbols

Determining Component Sizes

var contentSize: NSSize

The size of the scroll view’s content view.

var documentVisibleRect: NSRect

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

Managing Graphics Attributes

var backgroundColor: NSColor

The color of the content view’s background.

var drawsBackground: Bool

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

var borderType: NSBorderType

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

var documentCursor: NSCursor?

The content view’s document cursor.

Managing the Views

var contentView: NSClipView

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

var documentView: NSView?

The view the scroll view scrolls within its content view.

func addFloatingSubview(NSView, for: NSEventGestureAxis)

Adds a floating subview to the document view.

Managing Scrollers

var horizontalScroller: NSScroller?

The scroll view’s horizontal scroller.

var hasHorizontalScroller: Bool

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

var verticalScroller: NSScroller?

The scroll view’s vertical scroller.

var hasVerticalScroller: Bool

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

var autohidesScrollers: Bool

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

Managing Rulers

class func setRulerViewClass(AnyClass?)

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

class func rulerViewClass()

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

var hasHorizontalRuler: Bool

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

var horizontalRulerView: NSRulerView?

The scroll view’s horizontal ruler view.

var hasVerticalRuler: Bool

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

var verticalRulerView: NSRulerView?

The scroll view’s vertical ruler view.

var rulersVisible: Bool

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

Managing Insets

var automaticallyAdjustsContentInsets: Bool

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

var contentInsets: EdgeInsets

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

var scrollerInsets: EdgeInsets

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

Scroller Style

var scrollerKnobStyle: NSScrollerKnobStyle

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

var scrollerStyle: NSScrollerStyle

The scroller style used by the scroll view.

Setting Scrolling Behavior

var lineScroll: CGFloat

The scroll view’s line by line scroll amount.

var horizontalLineScroll: CGFloat

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

var verticalLineScroll: CGFloat

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

var pageScroll: CGFloat

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

var horizontalPageScroll: CGFloat

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

var verticalPageScroll: CGFloat

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

var scrollsDynamically: Bool

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

func scrollWheel(with: NSEvent)

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

Updating Display After Scrolling

func reflectScrolledClipView(NSClipView)

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

Arranging Components

func tile()

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

Find Bar Positioning

Specifying a Document’s Predominant Scrolling Behavior

var usesPredominantAxisScrolling: Bool

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

Specifying the Scroll View Elasticity

var horizontalScrollElasticity: NSScrollElasticity

The scroll view’s horizontal scrolling elasticity mode.

var verticalScrollElasticity: NSScrollElasticity

The scroll view’s vertical scrolling elasticity mode.

Flashing Overlay Scroll Bars

func flashScrollers()

Flash the overlay scroll bars.

Zooming the Scroll View

var allowsMagnification: Bool

Allows the user to magnify the scroll view.

var magnification: CGFloat

The amount by which the content is currently scaled.

func magnify(toFit: NSRect)

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

var maxMagnification: CGFloat

The maximum value to which the content can be magnified.

var minMagnification: CGFloat

The minimum value to which the content can be magnified.

func setMagnification(CGFloat, centeredAt: NSPoint)

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

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

static let NSScrollViewWillStartLiveMagnify: NSNotification.Name

Posted at the beginning of a magnify gesture.

static let NSScrollViewWillStartLiveScroll: NSNotification.Name

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

static let NSScrollViewDidLiveScroll: NSNotification.Name

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

static let NSScrollViewDidEndLiveScroll: NSNotification.Name

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

Relationships

Inherits From