透明的NSCollectionView背景 [英] Transparent NSCollectionView Background

查看:121
本文介绍了透明的NSCollectionView背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我再次努力将NSViews背景颜色设置为透明.我有一个NSCollectionView作为NSClipView的一部分,而NSClipViewNSScrollview的一部分.我的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆