How to toggle visibility of NSSplitView subView + hide Pane Splitter divider?

Dr.Kameleon picture Dr.Kameleon · Mar 23, 2012 · Viewed 7.5k times · Source

We have a parent Split view (NSSplitView), and two subviews, Content and SideBar (the sidebar is on the right).

What would be the optimal Cocoa-friendly way to toggle the SideBar view?

  • I would really love it, if the suggested solution includes animation
  • I really don't need any suggestions related to external plugins, etc (e.g. BWToolkit)

HINT : I've been trying to do that, but still I had issues hiding the divider of the NSSplitView as well. How could I do it, while hiding it at the same time?

Answer

Nathan Kinsinger picture Nathan Kinsinger · Mar 23, 2012

Here's a pretty decent tutorial that shows how to do this: Unraveling the Mysteries of NSSplitView.

Hiding the divider is done in NSSplitView's delegate method splitView:shouldHideDividerAtIndex:.

You will have to animate the frame size change yourself if you don't like the way NSSplitView does it.