How can I create Yosemite-style view with translucent/blurry background?

Kornel picture Kornel · Jun 3, 2014 · Viewed 23k times · Source

In Yosemite sidebars have a semitransparent "vibrant" background. How can I create a view like that in 10.10/Xcode 6?

Can I give any view such background? I've found that NSOutlineView will default to such background when you give it "Source list" highlight style, but the sidebar in the Calendar.app doesn't appear to be an NSOutlineView, so I wonder if there's a generic solution for this.

enter image description here

Answer

Kornel picture Kornel · Jun 4, 2014

w00t! I've found example code that uses not-yet-documented view type:

  1. Set XIB's deployment target to 10.10
  2. Embed your view in NSVisualEffectView
  3. In Interface Builder's settings for the view set appearance to "Vibrant Light/Dark". There are other options, like blending "Behind Window" or "Within Window" (the latter requires layers).

There's also NSView method allowsVibrancy that you can override to return YES, but for reasons I don't yet understand this didn't enable vibrancy in my case.