Created
November 1, 2017 17:51
-
-
Save KaneCheshire/dc55313d44387cf78125b8478e7dfe23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomCell: UICollectionViewCell { | |
@IBOutlet private var contentView: UIView! // Subview of `self` | |
@IBOutlet private var titleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var subtitleLabel: UIView! // Subview of `contentView` | |
@IBOutlet private var actionLabel: UIView! // Subview of `contentView` | |
private func setupAccessibility() { | |
contentView.isAccessibilityElement = true | |
let contentViewAccessibilityLabel = titleLabel.text + ", " + subtitleLabel.text | |
contentView.accessibilityLabel = contentViewAccessibilityLabel | |
actionLabel.isAccessibilityElement = true | |
actionLabel.accessibilityTraits = UIAccessibilityTraitButton | |
self.accessibilityElements = [contentView, actionLabel] // This determines the order as well | |
self.isAccessibilityElement = false // This is important! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment