objective-cmacoscocoanssplitview

How to change the NSSplitView divider thickness to 1px?


I would like to make the divider of an NSSplitView very thin, only 1px wide like Mail.app, Xcode.app, and many other Mac applications.

What is a good way to do this?

I have experimented with setting the divider style in Interface Builder as well as subclassing NSSplitView to override -dividerThickness, but the closest I have gotten is 2px, and this broke the divider functionality (I could no longer move the divider).

EDIT: I am aware of alternatives such as RBSplitView and BWSplitView, but I would like to use NSSplitView if possible. Basically, how does Apple do it?


Solution

  • You don't need to subclass NSSplitView or do any coding. You just need to set the Style to 'Thin Divider' in Xcode/Interface Builder (in Attributes Inspector).

    What might be confusing you is that you probably have subviews in the split views (most likely a table view). These subviews also have a border and when they fill the entire splitview it looks as if the split view divider is 2-3 pixels wide.

    So what you need to do is set the Focus Ring of all (filling) subviews to 'none' and either disable their border or move them slightly off the split view's frame by 1 px so the border is not visible.