透明的NSCollectionView背景 [英] Transparent NSCollectionView Background
问题描述
我再次努力将NSViews背景颜色设置为透明.我有一个NSCollectionView
作为NSClipView
的一部分,而NSClipView
是NSScrollview
的一部分.我的MainViewController
有一个collectionView
插座.添加两行代码并在编译后,背景有时是透明的,但大多数时候不是:
I'm again struggling with setting NSViews background colors to transparent. I have a NSCollectionView
as part of NSClipView
which is part of a NSScrollview
. My MainViewController
has an outlet to the collectionView
. With adding the two lines of code and after compiling the background is sometimes transparent but most of the times not:
view.wantsLayer = true
collectionView.layer?.backgroundColor = NSColor.clear.cgColor
我还尝试选择/取消选择IB中NSScrollView
的绘制背景"属性,而没有任何影响.
我在这里想念什么.
I also tried to select/de-select the "Draw Background" property of the NSScrollView
in the IB without any effects.
What do I miss here.
推荐答案
我试图让我的NSCollectionView背景透明" @JFS解决方案有点费劲,我朝着正确的方向努力:我最终通过设置 父滚动视图和collectionView背景:
I struggled a bit attempting to get my NSCollectionView background "transparent" @JFS solution pointed me in the right direction: and I finally achieved it by setting both the parent scrollView and the collectionView backgrounds:
cvScrollView.backgroundColor = NSColor.clear
collectionView.backgroundColors = [NSColor.clear]
这篇关于透明的NSCollectionView背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!