diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index 9c55d8a593..7b72403eb8 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -969,7 +969,6 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; if (_ASCollectionViewCell *asCell = ASDynamicCast(cell, _ASCollectionViewCell)) { asCell.node = node; - asCell.selectedBackgroundView = node.selectedBackgroundView; [_rangeController configureContentView:cell.contentView forCellNode:node]; } @@ -991,6 +990,10 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier"; ASCellNode *cellNode = [cell node]; cellNode.scrollView = collectionView; + + // Update the selected background view in collectionView:willDisplayCell:forItemAtIndexPath: otherwise it could be to + // early e.g. if the selectedBackgroundView was set in didLoad() + cell.selectedBackgroundView = cellNode.selectedBackgroundView; // Under iOS 10+, cells may be removed/re-added to the collection view without // receiving prepareForReuse/applyLayoutAttributes, as an optimization for e.g.