Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 901
Kornel Avatar asked Jun 03 '14 19:06

Kornel


1 Answers

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.

like image 191
Kornel Avatar answered Oct 02 '22 04:10

Kornel