2

My goal

I would like to add a vibrancy effect to a collection view.

The setup

I have the following view hierarchy:

enter image description here

When I use this layout, the background has the vibrancy effect as expected, but the performance is not quite there.

NSCollectionView is optimized to work with layer-backed views, so I enable the CALayer on the collection view's enclosing scroll view.

The problem

If I do this, the visual effect view is no longer visible, and the collection view has a white background.

My question

Is there any way to make a layer-backed view work together with NSVisualEffectView?

Community
  • 1
  • 1
József Vesza
  • 4,775
  • 3
  • 27
  • 42

1 Answers1

2

So if anyone's wondering, here's the trick:

  • adding the NSVisualEffectView: correct
  • making the enclosing scroll view layer-backed: correct
  • enabling the scroll view to draw a background: wrong

Make sure to either set drawsBackground to false, or disable it in Interface Builder, and your collection view will have the vibrant background, and fast scrolling as well

József Vesza
  • 4,775
  • 3
  • 27
  • 42