NSVisualEffectView behind NSScrollView

nsoutlineview, nsview, nsvisualeffectview, objective-c, osx-yosemite

Solution

Took me a while to find it, but there are a couple of new methods on NSWorkspace that you can use to find out about the preferences for OS X Yosemite’s new accessibility features. `-[NSWorkspace accessibilityDisplayShouldReduceTransparency]` is the one you want.

By Listening for `NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification` you can find out when that preference changes. Note that you’ll have to register for that notification on the correct `NSNotificationCenter`, that is `[[NSWorkspace sharedWorkspace] notificationCenter]`.

Problem

I'm trying to get my `NSScrollView` (and thus a contained `NSOutlineView`) to use a blurred `NSVisualEffectView` with behind-window blending effect. I've successfully made `NSVisualEffectView` the container view and placed my scroll view as a subview. This seems to work fine (as long as I make all my table cells, table, nsscrollview etc transparent). However I've now turned 'Reduce transparency' ON under Accessibility options and all of a sudden I have a black background behind my `NSScrollView`. I tried subclassing the visual effect view in order to override the `drawRect` method so that I can draw my own background, but I've just learned this isn't possible or recommended. How do I detect that Reduce Transparency is ON and how do I make my scrollview opaque dynamically?

Original source