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
class NSScrollViewMentioned in
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.
Touch scrolling
NSScrollView supports pull-to-refresh functionality. Assign an NSRefreshController to its refreshController property, and it initiates your target and action when someone pulls down past the top of the scrollable area.
By default, a single touch scrolls the view. If your content also needs to respond to single-touch gestures of its own — such as drawing or marking up a map — set minimumNumberOfTouchesForScrolling to a higher value, such as 2, so a single touch stays free for your own gesture recognizers and only multiple touches scroll the view. Use maximumNumberOfTouchesForScrolling alongside it to limit how many touches scrolling accepts. Set isTouchScrollingEnabled to false to turn off touch scrolling entirely, such as when your content already handles single-touch panning itself.
If your own gesture recognizers compete with the scroll view’s built-in scrolling and magnification gestures, use scrollGestureForRelationships to set up failure or exclusion relationships against them. For more information, see Prioritize gesture recognizers.
minimumNumberOfTouches and maximumNumberOfTouches replace numberOfTouchesRequired, which is deprecated. Set maximumNumberOfTouches to 0 to require exactly minimumNumberOfTouches touches; it defaults to NSIntegerMax.
For more information, see Adopting gesture recognizers in your app.
Topics
Creating a scroll view
Calculating layout
frameSize(forContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:)contentSize(forFrameSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:)
Determining component sizes
Managing graphics attributes
Managing the views
Managing scrollers
Managing rulers
Managing insets
Scroller style
Setting scrolling behavior
lineScrollhorizontalLineScrollverticalLineScrollpageScrollhorizontalPageScrollverticalPageScrollscrollsDynamicallyscrollWheel(with:)
Configuring touch scrolling
isTouchScrollingEnabledminimumNumberOfTouchesForScrollingmaximumNumberOfTouchesForScrollingscrollGestureForRelationshipsrefreshController
Updating display after scrolling
Arranging components
Find bar positioning
Specifying a document’s predominant scrolling behavior
Specifying the scroll view elasticity
Flashing overlay scroll bars
Zooming the scroll view
allowsMagnificationmagnificationmagnify(toFit:)maxMagnificationminMagnificationsetMagnification(_:centeredAt:)
Notifications
willStartLiveMagnifyNotificationNSScrollView.WillStartLiveMagnifyMessagedidEndLiveMagnifyNotificationNSScrollView.DidEndLiveMagnifyMessagewillStartLiveScrollNotificationNSScrollView.WillStartLiveScrollMessagedidLiveScrollNotificationNSScrollView.DidLiveScrollMessagedidEndLiveScrollNotificationNSScrollView.DidEndLiveScrollMessage