Skip to content

Instantly share code, notes, and snippets.

@KaneCheshire
Created November 1, 2017 17:48
Show Gist options
  • Save KaneCheshire/114017274605c6d30171a66a2bfa7a13 to your computer and use it in GitHub Desktop.
Save KaneCheshire/114017274605c6d30171a66a2bfa7a13 to your computer and use it in GitHub Desktop.
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment