add accessibility support

This commit is contained in:
Yonat Sharon 2019-07-11 00:23:13 +03:00
parent fdc9970154
commit 91de2684eb
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- add accessibility support.
## [1.3.6] - 2019-07-10
### Added

View File

@ -114,6 +114,10 @@ extension Int {
noLevelLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(noLevelLabel)
isAccessibilityElement = true
accessibilityIdentifier = "battery"
accessibilityLabel = "battery"
}
// MARK: - Layout
@ -160,8 +164,10 @@ extension Int {
let levelInset = (isVertical ? levelFrame.height : levelFrame.width) * CGFloat(.fullBattery - level) / CGFloat(Int.fullBattery)
(_, levelFrame) = levelFrame.divided(atDistance: levelInset, from: direction)
noLevelLabel.text = nil
accessibilityValue = level.description
} else {
noLevelLabel.text = noLevelText
accessibilityValue = noLevelText
}
levelFill.frame = levelFrame.integral
layoutCornerRadius()