Yosemite Vibrancy and NSScrollView

I have a toolbar right above an NSScrollView. To make things fit in with the new Yosemite look I’ve made the toolbar vibrant and moved it down to cover the top portion of the scrollview. It was easy and looks great.

But there’s a little problem. The scroller is a bit underneath the toolbar. That’s no good, sometimes you can’t even grab the scroll thumb. The obvious solution is to modify the size of the scroller to go up to the edge of the toolbar instead of all the way to the edge of the content view.

Looking through the NSScrollView docs doesn’t show any obvious way to do this. So after a bit of cursing at AppKit, I sat down and made a subclass that modifies the scroller frame. Not a big deal, but ugly, and probably not very future-proof.

Oh well. Code done and checked in. Moving on. That is, until I watched the 2014 WWDC session about vibrancy. It turns out that this situation was taken care of. And there are new properties on NSScrollView just for this use case. How did I miss this stuff?

It turns out the thing that’s missing is documentation. There are no mentions of insets anywhere in the NSScrollView docs. But the properties are definitely in the NSScrollView headers and even documented too.

@property BOOL automaticallyAdjustsContentInsets;
@property NSEdgeInsets contentInsets;
@property NSEdgeInsets scrollerInsets;

If you’re building something similar to me, then you’ll need to disable the automatic adjustment, then set the scrollerInset top inset to the height of your toolbar. Two lines of code and done. Subclass deleted. Yea!

Radar or GTFO: 20099948