Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/BrightnessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class BrightnessView: UIView {
init(frame: CGRect, color: UIColor) {
super.init(frame: frame)

// Enable direct interaction for VoiceOver users
self.isAccessibilityElement = true
self.accessibilityTraits |= UIAccessibilityTraitAllowsDirectInteraction

// Init the point at the correct position
point = getPointFromColor(color)

Expand Down
4 changes: 4 additions & 0 deletions Source/ColorWheel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class ColorWheel: UIView {

self.color = color

// Enable direct interaction for VoiceOver users
self.isAccessibilityElement = true
self.accessibilityTraits |= UIAccessibilityTraitAllowsDirectInteraction

// Layer for the Hue/Saturation wheel
wheelLayer = CALayer()
wheelLayer.frame = CGRect(x: 20, y: 20, width: self.frame.width-40, height: self.frame.height-40)
Expand Down
26 changes: 26 additions & 0 deletions Source/SelectedColorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ import UIKit
class SelectedColorView: UIView {
var color: UIColor!

// Describe color for VoiceOver users
override var accessibilityLabel: String? {
set { }
get {
var red: CGFloat = 0.0, green: CGFloat = 0.0, blue: CGFloat = 0.0
self.color.getRed(&red, green: &green, blue: &blue, alpha: nil)

let colorString = NSLocalizedString("Color", comment: "Title for color")
let redString = NSLocalizedString("Red", comment: "The color red")
let greenString = NSLocalizedString("Green", comment: "The color green")
let blueString = NSLocalizedString("Blue", comment: "The color blue")

let percentFormatter = NumberFormatter()
percentFormatter.numberStyle = .percent

let redPercent = percentFormatter.string(from: NSNumber(floatLiteral: Double(red)))!
let greenPercent = percentFormatter.string(from: NSNumber(floatLiteral: Double(green)))!
let bluePercent = percentFormatter.string(from: NSNumber(floatLiteral: Double(blue)))!

return "\(colorString), \(redPercent) \(redString), \(greenPercent) \(greenString), \(bluePercent) \(blueString)"
}
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
Expand All @@ -18,6 +41,9 @@ class SelectedColorView: UIView {
super.init(frame: frame)

setViewColor(color)

// Make accessible
self.isAccessibilityElement = true
}

func setViewColor(_ _color: UIColor) {
Expand Down