Change order of read items with VoiceOver

后端 未结 8 1191
醉话见心
醉话见心 2020-12-07 17:31

I have a bunch of buttons on the screen which are positioned intuitively visually but are not read in an intuitive order by VoiceOver. This is because certain buttons like U

8条回答
  •  抹茶落季
    2020-12-07 17:58

    I know this is an old thread, but I found that the easiest way to do it is to subclass UIView as such (Swift 3). Then simply modify your main UIView type in storyboard to AccessibiltySubviewsOrderedByTag and update the tags in each subview you want read in order.

    class AccessibilitySubviewsOrderedByTag: UIView {
        
        override func layoutSubviews() {
            
            self.accessibilityElements = [UIView]()
            for accessibilitySubview in self.subviews {
                if accessibilitySubview.isAccessibilityElement {
                    self.accessibilityElements?.append(accessibilitySubview)
                }
            }
            self.accessibilityElements?.sort(by: {($0 as AnyObject).tag < ($1 as AnyObject).tag})
        }
    }
    

提交回复
热议问题