I have a
UIButton and a
UILabel embedded in a
UIStackView, which looks something like this in Interface Builder:
By setting the
accessibilityLabel properties, I have been able to group the
UILabel into a single VoiceOver grouping, similar to this:
However with this configuration, the
UIButton (gray circle in the image above) becomes untappable, rendering the control useless.
Is there a way to maintain this grouping while still allowing the
UIButton to be tappable?
By default the
accessibilityActivationPoint for an accessibility element is the midpoint of its frame. When the button and the label got grouped into a new element the midpoint of their combined frame is no longer in the bounds of the button.
You can fix this by overriding the stack view's
accessibilityActivationPoint so that it returns the activation point of the button instead. Note that this property is in screen coordinates, so if the view moves on screen (for example scrolls) then it won't be enough to just set it once.