@@ -41,6 +41,7 @@ import UIKit
4141 @objc override open var title : String ? {
4242 didSet {
4343 titleButton? . setTitle ( title, for: . normal)
44+ updateAccessibility ( )
4445 }
4546 }
4647
@@ -89,7 +90,7 @@ import UIKit
8990 _titleView? . backgroundColor = UIColor . clear
9091
9192 titleButton = UIButton ( type: . system)
92- titleButton? . accessibilityTraits = . staticText
93+ titleButton? . isAccessibilityElement = false
9394 titleButton? . isEnabled = false
9495 titleButton? . titleLabel? . numberOfLines = 3
9596 titleButton? . setTitleColor ( UIColor . lightGray, for: . disabled)
@@ -141,4 +142,17 @@ import UIKit
141142 @objc required public init ? ( coder aDecoder: NSCoder ) {
142143 super. init ( coder: aDecoder)
143144 }
145+
146+ private func updateAccessibility( ) {
147+ if title == nil || title? . isEmpty == true {
148+ isAccessibilityElement = false
149+ accessibilityTraits = . none
150+ } else if titleButton? . isEnabled == true {
151+ isAccessibilityElement = true
152+ accessibilityTraits = . button
153+ } else {
154+ isAccessibilityElement = true
155+ accessibilityTraits = . staticText
156+ }
157+ }
144158}
0 commit comments