1

I have a collectionView set on a SCNMaterial. The collectionView's background color is .clear and so is the background color of the view controller the the collectionView is in

collectionView.backgroundColor = .clear
view.backgroundColor = .clear // collectionView's superview

The cells are yellow. There is a minimumLineSpacing set to 10. The background color to the SCNPlane geometry defaults to white and since the collectionView's view is .clear the SCNPlane's background color is visible which shows white.

This gets me:

// 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

I want:

// 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

If I set the SCNNode's node.opacity = 0 or node.geometry?.firstMaterial?.transparency = 0 nothing is visible, since the collectionView is a child of the node it becomes invisible also.

How can I set the SCNNode's background color to clear without affecting the cells/cv/cv's parent?

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)

enter image description here

It's possible to do this because I found this pic on this guy's question

Lance Samaria
  • 17,576
  • 18
  • 108
  • 256

0 Answers0