Skip to content

Commit

Permalink
[MDC Dragons] Fix MDCBaseCell Example to work with Voice Over (#8953)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
galiak11 committed Nov 15, 2019
1 parent 5310c5c commit 722399d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/List/examples/MDCBaseCellExample.m
Expand Up @@ -83,19 +83,23 @@ - (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;
}

- (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
Expand Down

0 comments on commit 722399d

Please sign in to comment.