ensure range is valid.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-03-20 15:29:24 -05:00
parent 1d9667c173
commit 0fc70e9f75

View File

@ -344,7 +344,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
for attribute in attributes {
//see if the attribute is Actionable
if let actionable = attribute as? any ActionLabelAttributeModel{
if let actionable = attribute as? any ActionLabelAttributeModel, mutableAttributedString.isValid(range: actionable.range) {
//create a accessibleAction
let customAccessibilityAction = customAccessibilityAction(text: mutableAttributedString.string, range: actionable.range, accessibleText: actionable.accessibleText)
@ -379,7 +379,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
guard let text = text, let attributedText else { return nil }
let actionText = accessibleText ?? NSString(string:text).substring(with: range)
let actionText = accessibleText ?? (text.isValid(range: range) ? NSString(string:text).substring(with: range) : text)
// Calculate the frame of the substring
let layoutManager = NSLayoutManager()