Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
700 views
in Technique[技术] by (71.8m points)

macos - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...