Setting Background Configuration on Default UICollectionViewListCell for Various States

Here is my code currently. The problem is that the beige background color is there even when I select the cell. I know I should set a different background configuration for every state that I need to, but I don't know how for this default cell. I have created custom UICollectionViewListCells and set a different background on those depending on state. But can't figure out how to do that with the default cells.

Code Block
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, CellItem> { (cell, indexPath, cellItem) in
            var content = cell.defaultContentConfiguration()
            content.text = cellItem.title
            content.secondaryText = cellItem.subText
           
            if let imageName = cellItem.imageName {
                content.image = UIImage(named: imageName)
            }
            cell.contentConfiguration = content
            cell.accessories = [.disclosureIndicator()]
            
            var backgroundConfig = UIBackgroundConfiguration.listGroupedCell()
           /* Set a beige background color to use the cell's tint color. */
            backgroundConfig.backgroundColor = UIColor(named: "CellColor")
            backgroundConfig.strokeColor = .green
            cell.backgroundConfiguration = backgroundConfig
        }



Answered by Frameworks Engineer in 621544022
If you want to customize the background configuration for specific states, you need to override updateConfiguration(using state:) in a cell subclass, which is called anytime the state changes so you'll be able to update the configuration as desired for the new state.

Setting a background configuration on the cell with customized properties won't allow the appearance to change for different states; only non-customized properties are automatically updated based on the default values for the configuration in the new state.
Looks like the newest version of the WWDC code answers my question. Thanks to Apple.
Accepted Answer
If you want to customize the background configuration for specific states, you need to override updateConfiguration(using state:) in a cell subclass, which is called anytime the state changes so you'll be able to update the configuration as desired for the new state.

Setting a background configuration on the cell with customized properties won't allow the appearance to change for different states; only non-customized properties are automatically updated based on the default values for the configuration in the new state.
Thanks for the answer. That correlates with the most recent WWDC code.
Setting Background Configuration on Default UICollectionViewListCell for Various States
 
 
Q