TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.
https://texturegroup.org/
Other
8.02k stars 1.3k forks source link

Cell selection not visible after setting ASCellNode backgroundColor on iOS 13 or later #2016

Open denkeni opened 3 years ago

denkeni commented 3 years ago

Problem Statement

I created a sample project for this bug. UIKit and Texture behaviors can be compared side by side.

Texture_issue

When setting backgroundColor of ASCellNode, Texture has been setting backgroundColor on both _ASDisplayView (added on top of contentView) and underlying _ASTableViewCell.

Behavior_Texture

This bug happens on iOS 13 or later, which may result from UIKit behavior change.

Prior to iOS 13, UIKit would make _ASDisplayView transparent when cell is selected. This behavior no longer works on iOS 13 or later, which results in opaque _ASDisplayView blocking selection color below (UITableViewCellSelectedBackground).

Discussion for Possible Solutions

  1. In some example projects, [self updateBackgroundColor] was used in setSelected: of ASCellNode. If this is the suggested way going forward, it should be better documented.

  2. We may have a workaround by assigning cellNode.backgroundColor in nodeBlockForRowAt, and then setting cellNode.backgroundColor = nil in willDisplayRowWith. Not a good solution.

  3. In Texture, we may set node.backgroundColor = nil right after self.backgroundColor = node.backgroundColor; (backgroundColor has been passed to underlying _ASTableViewCell). However, this may only work when node.background is set inside ASCellNodeBlock.

  4. In Texture, we may create another UITableViewCell specific passthrough property "backgroundColor" on ASCellNode, so backgroundColor would not go up to superclass ASDisplayNode and thus _ASDisplayView. However, ASCellNode does not pass backgroundColor to underlying _ASCollectionViewCell for other reasons, which will cause other issues.

Any other ideas?