![](https://user-images.githubusercontent.com/1390908/41822361-a14fafd2-77ee-11e8-8aa6-f18960566d0c.png)
Accessibility for iOS, macOS, tvOS, and watchOS
Documentation
Capable offers a whole lot of features along with a bunch of configurations. To find more about how to use them inside the documentation section.
CocoaPods
use_frameworks!
target 'MyApp' do
pod 'Capable'
end
Carthage
github "chrs1885/Capable"
Swift Package Manager
dependencies: [
.package(url: "https://github.com/chrs1885/Capable.git", from: "2.0.1")
]
Register for (specific) accessibility settings
Firstly, you need to import the Capable framework in your class by adding the following import statement:
import Capable
There are two different ways to initialize the framework instance. You can either set it up to consider all accessibility features
let capable = Capable()
or by passing in only specific feature names
let capable = Capable(withFeatures: [.largerText, .boldText, .shakeToUndo])
You can find a list of all accessibility features available on each platform in the accessibility feature overview section.
Get accessibility status
If you are interested in a specific accessibility feature, you can retrieve its current status as follows:
let capable = Capable()
let isVoiceOverEnabled: Bool = capable.isFeatureEnable(feature: .voiceOver)
To get a dictionary of all features, that the Capable
instance has been initialized with you can use:
let capable = Capable()
let statusMap = capable.statusMap
This will return each feature name (key) along with its current value as described in the accessibility feature overview section.
Send accessibility status
The statusMap
object is compatible with most analytic SDK APIs. Here’s a quick example of how to send your data along with user properties or custom events.
func sendMetrics() {
let statusMap = self.capable.statusMap
let eventName = "Capable features received"
// App Center
MSAnalytics.trackEvent(eventName, withProperties: statusMap)
// Firebase
Analytics.logEvent(eventName, parameters: statusMap)
// Fabric
Answers.logCustomEvent(withName: eventName, customAttributes: statusMap)
}
Listen for settings changes
After initialization, notifications for all features that have been registered can be retrieved. To react to changes, you need to add your class as an observer as follows:
NotificationCenter.default.addObserver(
self,
selector: #selector(self.featureStatusChanged),
name: .CapableFeatureStatusDidChange,
object: nil)
Inside your featureStatusChanged
you can parse the specific feature and value:
@objc private func featureStatusChanged(notification: NSNotification) {
if let featureStatus = notification.object as? FeatureStatus {
let feature = featureStatus.feature
let currentValue = featureStatus.statusString
}
}
LargerText
iOS
- XS
- S
- M (default)
- L
- XL
- XXL
- XXXL
- Accessibility M
- Accessibility L
- Accessibility XL
- Accessibility XXL
- Accessibility XXXL
- Unknown
watchOS
- XS
- S (default watch with 38mm)
- L (default watch with 42mm)
- XL
- XXL
- XXXL
- Unknown
HearingDevice
- both
- left
- right
- disabled