objective-ccocoansviewnsscrollviewnsscroller

Overlay NSScroller over content


Is there any way to overlay the NSScroller over the content of the scroll view (like in iOS)? I've already tried several approaches:

a) setting the frame of the scroll view content view (NSClipView) to extend into the bounds of the scroller

b) adding an NSScroller object as a subview of the scroll view (positioned where I want)

c) creating an entirely custom scroller view and placing it as a subview (this worked, but that would mean that I need to rewrite all the functionality of NSScroller)

Sparrow seems to successfully do this, and it seems to do it through a regular NSScroller subclass (seeing as it responds to the scroll settings set in System Preferences >> Appearance). It's not really drawing the scroller that's the issue, its just making it overlay the content.

Any advice is appreciated :-)


Solution

  • Here's where you can set the custom class of your scrollbars.

    After that, by overriding the -tile method of NSScrollView, you'll get them placed properly.