我在SCNMaterial上设置了collectionView。 collectionView的背景色是.clear,collectionView所在的视图控制器的背景色也是。
collectionView.backgroundColor = .clear
view.backgroundColor = .clear // collectionView's superview
细胞为黄色。最小LineSpacing设置为10。SCNPlane几何的背景色默认为白色,并且由于collectionView的视图为.clear,因此SCNPlane的背景色可见,显示为白色。
这让我:
// this makes it appear the cells are sitting on either a white background or on top of another white cell
yellowCell_0
mimLineSpacing > white background color from SCNNode
yellowCell_1
mimLineSpacing > white background color from SCNNode
yellowCell_2
mimLineSpacing > white background color from SCNNode
etc
我想要:
// this makes it appear the cells are sitting on nothing, a clear background, or on top of clear cells
yellowCell_0
mimLineSpacing > clear background color from SCNNode
yellowCell_1
mimLineSpacing > clear background color from SCNNode
yellowCell_2
mimLineSpacing > clear background color from SCNNode
etc
如果我设置SCNNode的node.opacity = 0
或node.geometry?.firstMaterial?.transparency = 0
,则看不见任何东西,因为collectionView是该节点的子节点,因此它也变得不可见。
如何在不影响cell / cv / cv父对象的情况下将SCNNode的背景颜色设置为透明?
let material = SCNMaterial()
material.diffuse.contents = myCollectionView.view // has yellow cells
let plane = SCNPlane(width: 0.5, height: 0.5)
plane.materials = [material]
let node = SCNNode(geometry: plane)
// node.opacity = 0.0
// node.geometry?.firstMaterial?.transparency = 0.0
node.position = SCNVector3(0.0, 0.0, 0.0)
之所以可以这样做是因为我在this pic上找到了this guy's question