objective-cmacosswiftcocoansvisualeffectview

NSScrollView/NSCollectionView on NSVisualEffectView cause flickering


I have a NSCollectionView within a NSVisualEffectView within a NSPopover. Everytime when it's refreshing(add, remove, reload NSCollectionViewItem, or even just click buttons on the NSCollectionViewItem's view), it has glitches on the controls.

Here's a screenshot I try to get when it's opening:

Flickering

It's more or less like this but only when the redrawing happens:

enter image description here

Also, if I put a button with border off on it, when clicked the color went off, just like the flickering:

enter image description here

I tried to set background color in different views/controls, but seems the NSCollectionView will always be black/white (depending on UI color selection) when it's empty:

enter image description here

Did I missed anything?

EDIT:

By adding scrollView.needsDisplay = false/true before/after the item change will make some of the flickers gone. Still, most the problems still exist.

Also, if I forcely enabled horizontal scroller bar or disabled autoresize subview, the flicker will no longer show when add/remove items.


Solution

  • Ok, seems disabling the "Autoresize Subviews" on the problematic view will do the trick.