add setter to label

This commit is contained in:
Pfeil, Scott Robert 2019-06-21 13:48:29 -04:00
parent cb8ad83149
commit fe09ce04dc

View File

@ -398,11 +398,10 @@ extension Label {
}
}
func addDefaultAttributes(range: NSRange, string: NSAttributedString?) {
func addDefaultAttributes(range: NSRange, string: NSMutableAttributedString?) {
guard let string = string else { return }
let mutableAttributedString = NSMutableAttributedString(attributedString: string)
mutableAttributedString.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
}
fileprivate func setDefaultAttributes(range: NSRange) {
@ -410,8 +409,7 @@ extension Label {
guard let attributedText = attributedText else { return }
let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText)
mutableAttributedString.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
addDefaultAttributes(range: range, string: mutableAttributedString)
self.attributedText = mutableAttributedString
}