Mac Developer Library

Developer

AppKit Framework Reference NSSplitView Class Reference

Options
Deployment Target:

On This Page
Language:

NSSplitView

A split view manages the dividers and orientation for a split view controller (an instance of the NSSplitViewController class.) By default, dividers are oriented horizontally so that sibling views are arranged vertically, from top to bottom, in the containing split view controller. More...

Inheritance


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.0 and later.
  • Adjusts the sizes of the split view’s subviews so they (plus the dividers) fill the split view.

    Declaration

    Swift

    func adjustSubviews()

    Objective-C

    - (void)adjustSubviews

    Discussion

    When you call this method, the split view’s subviews are resized proportionally; the relative sizes of the subviews do not change.

    The default implementation of this method resizes subviews proportionally so that the ratio of heights (when using horizontal dividers) or widths (when using vertical dividers) does not change, even though the absolute sizes change.

    Call this method on split views from which subviews have been added or removed, to reestablish the consistency of subview placement.

    This method invalidates the cursor when it is over a divider, ensuring the cursor is always of the correct type during and after resizing animations.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setDelegate:
    setFrame: (in NSView Class Reference)

  • Returns whether the specified view is collapsed.

    Declaration

    Swift

    func isSubviewCollapsed(_ subview: NSView) -> Bool

    Objective-C

    - (BOOL)isSubviewCollapsed:(NSView *)subview

    Parameters

    subview

    The subview in the split view.

    Return Value

    YEStrue if subview is in a collapsed state, NOfalse otherwise.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the priority of the subview’s width or height when resizing.

    Declaration

    Swift

    func holdingPriorityForSubviewAtIndex(_ subviewIndex: Int) -> NSLayoutPriority

    Objective-C

    - (NSLayoutPriority)holdingPriorityForSubviewAtIndex:(NSInteger)subviewIndex

    Parameters

    subviewIndex

    The index of the subview.

    Return Value

    Returns the layout priority of the subview at the index.

    Discussion

    The priority is the manner under which split view subviews hold their widths (for a vertical split view) or height (for a horizontal split view). The view with the lowest priority will be the first to take on additional width if the split view grows or shrinks.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • Sets the priority under which split view subviews maintain their width or height.

    Declaration

    Swift

    func setHoldingPriority(_ priority: NSLayoutPriority, forSubviewAtIndex subviewIndex: Int)

    Objective-C

    - (void)setHoldingPriority:(NSLayoutPriority)priority forSubviewAtIndex:(NSInteger)subviewIndex

    Parameters

    priority

    The priority.

    subviewIndex

    The index of the subview

    Discussion

    Sets the priority under which split view subviews hold their widths (for a vertical split view) or height (for a horizontal split view). The view with the lowest priority will be the first to take on additional width if the split view grows or shrinks.

    The default is NSLayoutPriorityDefaultLow. There is no reason to use the default, but you should use priorities less than NSLayoutPriorityDragThatCannotResizeWindow.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • vertical vertical Property

    The geometric orientation of the split view's dividers, where YES results in vertical dividers and side-by-side views.

    Declaration

    Swift

    var vertical: Bool

    Objective-C

    @property(getter=isVertical) BOOL vertical

    Discussion

    The default value of this property is NOfalse, indicating horizontal dividers and, consequently, views that are stacked one above the other (from top to bottom) in the containing split view controller’s view.

    To specify vertical dividers and, consequently, horizontal (side-by-side) arrangement of views within a split view controller, implement this property to return YEStrue.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The style of divider drawn between views.

    Declaration

    Swift

    var dividerStyle: NSSplitViewDividerStyle

    Objective-C

    @property NSSplitViewDividerStyle dividerStyle

    Discussion

    The possible values are described in Split View Divider Styles.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The color of the dividers that the split view draws between subviews.

    Declaration

    Swift

    @NSCopying var dividerColor: NSColor { get }

    Objective-C

    @property(readonly, copy) NSColor *dividerColor

    Discussion

    The default implementation of this method returns clearColor when dividerStyle returns NSSplitViewDividerStyleThick or when dividerStyle returns NSSplitViewDividerStylePaneSplitter and the receiver is in a textured window. All other thin dividers are drawn with a color that looks good between two white panes.

    You can subclass NSSplitView and override this method to change the color of dividers.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The thickness of the dividers for the split view.

    Declaration

    Swift

    var dividerThickness: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat dividerThickness

    Discussion

    You can subclass NSSplitView and override this method to change the thickness of a split view’s dividers.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Draws a divider between two of the receiver’s subviews.

    Declaration

    Swift

    func drawDividerInRect(_ aRect: NSRect)

    Objective-C

    - (void)drawDividerInRect:(NSRect)aRect

    Parameters

    aRect

    The entire divider rectangle in the split view’s coordinate system, which is flipped.

    Discussion

    If you override this method and use a custom icon to identify the divider, you may need to change the size of the divider.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The name under which split view’s divider configuration is automatically saved.

    Declaration

    Swift

    var autosaveName: String?

    Objective-C

    @property(copy) NSString *autosaveName

    Discussion

    If this property’s value is nil or empty, no autosaving is performed.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the minimum possible position of the divider at the specified index.

    Declaration

    Swift

    func minPossiblePositionOfDividerAtIndex(_ dividerIndex: Int) -> CGFloat

    Objective-C

    - (CGFloat)minPossiblePositionOfDividerAtIndex:(NSInteger)dividerIndex

    Parameters

    dividerIndex

    The index of the divider.

    Return Value

    A CGFloat specifying the minimum possible position of the divider.

    Discussion

    The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.

    You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:.

    You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt: to implement relatively complex behaviors that depend on the current state of the split view.

    The results of invoking this method when adjustSubviews has not been invoked, and the subview frames are invalid, is undefined.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the maximum possible position of the divider at the specified index.

    Declaration

    Swift

    func maxPossiblePositionOfDividerAtIndex(_ dividerIndex: Int) -> CGFloat

    Objective-C

    - (CGFloat)maxPossiblePositionOfDividerAtIndex:(NSInteger)dividerIndex

    Parameters

    dividerIndex

    The index of the divider.

    Return Value

    A CGFloat specifying the maximum possible position of the divider.

    Discussion

    The position is "possible" in that it is dictated by the bounds of the receiver and the current position of other dividers. "Allowable" positions are those that result from letting the delegate apply constraints to the possible positions.

    You can invoke this method to determine the range of values that can be usefully passed to setPosition:ofDividerAtIndex:.

    You can also invoke it from delegate methods like splitView:constrainSplitPosition:ofSubviewAt: to implement relatively complex behaviors that depend on the current state of the split view.

    The results of invoking this method when adjustSubviews has not been invoked, and the subview frames are invalid, is undefined.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sets the position of the divider at the specified index.

    Declaration

    Swift

    func setPosition(_ position: CGFloat, ofDividerAtIndex dividerIndex: Int)

    Objective-C

    - (void)setPosition:(CGFloat)position ofDividerAtIndex:(NSInteger)dividerIndex

    Parameters

    position

    The position of the divider

    dividerIndex

    The index of the divider.

    Discussion

    The default implementation of this method behaves as if the user were attempting to drag the divider to the proposed position, so the constraints imposed by the delegate are applied and one of the views adjacent to the divider may be collapsed.

    This method is not invoked by NSSplitView itself.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns YEStrue if the receiver’s splitter is a bar that goes across the split view. Returns NOfalse if the splitter is a thumb on the regular background pattern.

    Deprecation Statement

    This functionality is no longer relevant and there is no alternative method.

    Declaration

    Objective-C

    - (BOOL)isPaneSplitter

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • Sets the type of splitter.

    Deprecation Statement

    This functionality is no longer relevant and there is no alternative method.

    Declaration

    Objective-C

    - (void)setIsPaneSplitter:(BOOL)flag

    Parameters

    flag

    YEStrue if the receiver’s splitter is a bar that goes across the split view. NOfalse if the splitter is a thumb on the regular background pattern.

    Import Statement

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.6.

  • These constants specify the possible divider styles used by dividerStyle and setDividerStyle:.

    Declaration

    Swift

    enum NSSplitViewDividerStyle : Int { case Thick case Thin case PaneSplitter }

    Objective-C

    enum { NSSplitViewDividerStyleThick = 1, NSSplitViewDividerStyleThin = 2, NSSplitViewDividerStylePaneSplitter = 3, }; typedef NSInteger NSSplitViewDividerStyle;

    Constants

    • Thick

      NSSplitViewDividerStyleThick

      A thick style divider is displayed between subviews. This is the default.

      Available in OS X v10.5 and later.

    • Thin

      NSSplitViewDividerStyleThin

      A thin style divider is displayed between subviews.

      Available in OS X v10.5 and later.

    • PaneSplitter

      NSSplitViewDividerStylePaneSplitter

      A thick style divider with a 3D appearance is displayed between subviews.

      Available in OS X v10.6 and later.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Posted after an NSSplitView changes the sizes of some or all of its subviews. The notification object is the NSSplitView that resized its subviews.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Posted before an NSSplitView changes the sizes of some or all of its subviews. The notification object is the NSSplitView object that is about to resize its subviews.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.