From 722399ddce71f214211651d01bdbf344f9c9829c Mon Sep 17 00:00:00 2001 From: Galia Kaufman Date: Fri, 15 Nov 2019 15:27:26 -0500 Subject: [PATCH] [MDC Dragons] Fix MDCBaseCell Example to work with Voice Over (#8953) Make sure List cells are accessible to Voice Over and have a label that distinguish them from each other, and have the selected trait when selected. --- components/List/examples/MDCBaseCellExample.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/List/examples/MDCBaseCellExample.m b/components/List/examples/MDCBaseCellExample.m index 8b41ac626f9..03d234b2e2b 100644 --- a/components/List/examples/MDCBaseCellExample.m +++ b/components/List/examples/MDCBaseCellExample.m @@ -83,6 +83,8 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell.layer.borderWidth = 1; cell.enableRippleBehavior = YES; cell.rippleColor = [UIColor colorWithRed:0 green:(CGFloat)0 blue:(CGFloat)0 alpha:(CGFloat)0.1]; + cell.isAccessibilityElement = YES; + cell.accessibilityLabel = [NSString stringWithFormat:@"Cell number %d", indexPath.item]; return cell; } @@ -90,12 +92,14 @@ - (void)collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath { MDCBaseCell *cell = (MDCBaseCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; cell.elevation = 10; + cell.accessibilityTraits |= UIAccessibilityTraitSelected; } - (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath { MDCBaseCell *cell = (MDCBaseCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; cell.elevation = 0; + cell.accessibilityTraits &= ~UIAccessibilityTraitSelected; } #pragma mark - CatalogByConvention