@@ -117,7 +117,9 @@ public final class MessageView: UIView, MessageTextViewListener {
117
117
get { return textView. textContainerInset }
118
118
}
119
119
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 ) {
121
123
let button : UIButton
122
124
switch position {
123
125
case . left:
@@ -126,10 +128,13 @@ public final class MessageView: UIView, MessageTextViewListener {
126
128
button = rightButton
127
129
}
128
130
button. setImage ( icon, for: state)
131
+ button. accessibilityLabel = accessibilityLabel ?? icon? . accessibilityIdentifier
129
132
buttonLayoutDidChange ( button: button)
130
133
}
131
134
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 ) {
133
138
let button : UIButton
134
139
switch position {
135
140
case . left:
@@ -138,6 +143,7 @@ public final class MessageView: UIView, MessageTextViewListener {
138
143
button = rightButton
139
144
}
140
145
button. setTitle ( title, for: state)
146
+ button. accessibilityLabel = accessibilityLabel ?? title
141
147
buttonLayoutDidChange ( button: button)
142
148
}
143
149
0 commit comments