fix label overriding itself

This commit is contained in:
Pfeil, Scott Robert 2019-06-21 13:34:02 -04:00
parent 9f038467a9
commit cb8ad83149

View File

@ -247,10 +247,11 @@ public typealias ActionBlock = () -> Void
case "action":
guard let actionLabel = label as? Label else { continue }
actionLabel.addTappableLinkAttribute(range: range,
actionMap: json,
additionalData: additionalData,
delegateObject: delegate)
actionLabel.addDefaultAttributes(range: range, string: attributedString)
actionLabel.clauses.append(ActionableClause(range: range,
actionBlock: actionLabel.createActionBlockFrom(actionMap: json,
additionalData: additionalData,
delegateObject: delegate)))
default:
continue
}
@ -397,6 +398,13 @@ extension Label {
}
}
func addDefaultAttributes(range: NSRange, string: NSAttributedString?) {
guard let string = string else { return }
let mutableAttributedString = NSMutableAttributedString(attributedString: string)
mutableAttributedString.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
}
fileprivate func setDefaultAttributes(range: NSRange) {
guard let attributedText = attributedText else { return }