I have a view hierarchy as follows:
UIView
\-- UIStackView
+-- UILabel
\-- UILabel
By default, VoiceOver skips over the UIView
and stops on each of the UILabel
s separately.
I would like VoiceOver to stop on the UIView
and combine its contents (i.e. read the accessibility label of each of its accessible children one by one). Does UIKit offer an API to achieve this similar to SwiftUI's accessibilityElement(children: .combine) API?
Notes
- I know I can set
isAccessibilityElement
totrue
on theUIView
and then set itsaccessibilityLabel
to"\(label1.text!) \(label2.text!)"
. I'm wondering whether there is an automatic means of achieving this which doesn't require me to define theUIView
'saccessibilityLabel
. - The problem with having to define the
UIView
'saccessibilityLabel
manually based on its children is that I have to remember to change theUIView
'saccessibilityLabel
in every place where thetext
oraccessibilityLabel
of any of its children changes.