Skip to content

Instantly share code, notes, and snippets.

@yunustek
Created January 7, 2019 19:57
Show Gist options
  • Save yunustek/48f5d67996b363c64957158064764b76 to your computer and use it in GitHub Desktop.
Save yunustek/48f5d67996b363c64957158064764b76 to your computer and use it in GitHub Desktop.
iOS Accesibility
func configureAccessibility(_ account: Account) {
photoButton.isAccessibilityElement = true
usernameLabel.isAccessibilityElement = true
pointButton.isAccessibilityElement = true
photoButton.accessibilityTraits = .button
usernameLabel.accessibilityTraits = .staticText
pointButton.accessibilityTraits = .button
//Point Button
//Label Value - Accessibility Value - Hint Value: Bu okunacak sıradır.
pointButton.accessibilityLabel = "Puan"
switch account.pointCount {
case 0:
pointButton.accessibilityValue = "Bulunmuyor"
default:
pointButton.accessibilityValue = "\(account.pointCount) puan var"
}
pointButton.accessibilityHint = "Puanlar hakkında detayları açıklar"
//Username Label
usernameLabel.accessibilityLabel = "Adın"
usernameLabel.accessibilityValue = account.username
usernameLabel.accessibilityHint = "Adın hakkında bilgiyi açıklar"
//Photo Button
photoButton.accessibilityLabel = "Fotoğraf"
switch account.photo {
case nil:
photoButton.accessibilityValue = "Bulunmuyor"
default:
photoButton.accessibilityValue = "Burada bir fotoğrafın bulunuyor"
}
photoButton.accessibilityHint = "Fotoğraf değiştirmeyi sağlar"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment