macoscalayernsviewnswindownsvisualeffectview

How to use NSVisualEffectView in a Layer Host NSView


I have a NSView in my OSX app use CALayer doing all sort of animations. This view is a layer host view which contains many small layers.

I want to add a NSVisualEffectView with NSVisualEffectBlendingModeBehindWindow blendingMode to support blur transparency effect on Yosemite.

The problem is when I turn off layer host view, the NSVisualEffectView works, but when I turn on the layer host view, the blur transparency effect goes away, leaving a blank white opaque background.

My question is: "is it possible to use a NSVisualEffectView with Layer host view? If it is doable, what is the approach here?"


Solution

  • It turns out that I made a NSVisualEffectView to a layer host view which will cause this problem.

    The solution is adding 2 views: the one below is a NSVisualEffectView. the one above is a NSView layer host view.

    This will solve the problem.