@@ -117,7 +117,9 @@ public final class MessageView: UIView, MessageTextViewListener {
117117 get { return textView. textContainerInset }
118118 }
119119
120- public func setButton( icon: UIImage ? , for state: UIControlState , position: ButtonPosition ) {
120+ /// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
121+ /// If none is supplied, it will default to the icon's `accessibilityLabel`.
122+ public func setButton( icon: UIImage ? , for state: UIControlState , position: ButtonPosition , accessibilityLabel: String ? = nil ) {
121123 let button : UIButton
122124 switch position {
123125 case . left:
@@ -126,10 +128,13 @@ public final class MessageView: UIView, MessageTextViewListener {
126128 button = rightButton
127129 }
128130 button. setImage ( icon, for: state)
131+ button. accessibilityLabel = accessibilityLabel ?? icon? . accessibilityIdentifier
129132 buttonLayoutDidChange ( button: button)
130133 }
131134
132- public func setButton( title: String , for state: UIControlState , position: ButtonPosition ) {
135+ /// - Parameter accessibilityLabel: A custom `accessibilityLabel` to set on the button.
136+ /// If none is supplied, it will default to the the supplied `title`.
137+ public func setButton( title: String , for state: UIControlState , position: ButtonPosition , accessibilityLabel: String ? = nil ) {
133138 let button : UIButton
134139 switch position {
135140 case . left:
@@ -138,6 +143,7 @@ public final class MessageView: UIView, MessageTextViewListener {
138143 button = rightButton
139144 }
140145 button. setTitle ( title, for: state)
146+ button. accessibilityLabel = accessibilityLabel ?? title
141147 buttonLayoutDidChange ( button: button)
142148 }
143149
0 commit comments