Add accessibility to milestone cell (#1255)

This commit is contained in:
Bas Broek
2017-12-17 04:11:31 +01:00
committed by Ryan Nystrom
parent a9956f073f
commit d031d752f5

View File

@@ -16,6 +16,8 @@ final class IssueMilestoneCell: UICollectionViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
isAccessibilityElement = true
accessibilityTraits |= UIAccessibilityTraitButton
titleLabel.backgroundColor = .clear
contentView.addSubview(titleLabel)
@@ -60,6 +62,10 @@ final class IssueMilestoneCell: UICollectionViewCell {
titleLabel.attributedText = titleText
progress.progress = Float(milestone.totalIssueCount - milestone.openIssueCount) / Float(milestone.totalIssueCount)
let milestoneFormat = NSLocalizedString("Milestone: %@, %.0f percent completed.", comment: "The accessibility label for a repositories' milestone")
let percentProgress = progress.progress * 100
accessibilityLabel = String(format: milestoneFormat, arguments: [milestone.title, percentProgress])
}
}