fixed bug for Accessibility Elements in Label

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-06-05 17:32:45 -05:00
parent a71085f2b3
commit f5380532ff

View File

@ -314,8 +314,11 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
super.text = newValue
return
}
//clear out accessibility
accessibilityElements?.removeAll()
accessibilityCustomActions = []
//create the primary string
let mutableText = NSMutableAttributedString.mutableText(for: newValue,
textStyle: textStyle,
@ -337,6 +340,10 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
return
}
//clear out accessibility
accessibilityElements?.removeAll()
accessibilityCustomActions = []
let mutableText = NSMutableAttributedString(attributedString: newValue)
applyAttributes(mutableText)
@ -348,7 +355,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
private func applyAttributes(_ mutableAttributedString: NSMutableAttributedString) {
actions = []
if let attributes = attributes {
if let attributes {
mutableAttributedString.apply(attributes: attributes)
}
}
@ -359,7 +366,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText)
if let attributes = attributes {
if let attributes {
//loop through the models attributes
for attribute in attributes {