On the following iOS screen the slider uses VoiceOver in a specific way
The 'SPEAKING RATE' UISlider reads information about the slider when clicked:
"Speaking rate 65% adjustable. Slide up or down to adjust the value"
I'd like my UISlider
to read out similarly. Instead I get "Volume Control, 50%, Adjustable". What am I doing wrong? Here is my code:
import UIKit
class ViewController: UIViewController {
let slider = UISlider()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Set up the slider
slider.frame = CGRect(x: 50, y: 100, width: 200, height: 20)
slider.minimumValue = 0
slider.maximumValue = 100
slider.accessibilityIncrement()
slider.value = 50
// Set accessibility properties for the slider
slider.isAccessibilityElement = true
slider.accessibilityLabel = "Volume Control"
slider.accessibilityValue = "\(Int(slider.value))%"
slider.accessibilityTraits = .adjustable
// Add the slider to the view
view.addSubview(slider)
}
}
Don't worry, you're doing nothing wrong in your code. 😉
Take a look in the user settings ⟹ Accessibility - VoiceOver - Verbosity - Speak Hints...
... and you'll reach your goal to get VoiceOver for a UISlider to read like in the iOS Settings. 🎉👍
Unfortunately, there's no notification to be aware of this value. 😓