add setter to label
This commit is contained in:
parent
cb8ad83149
commit
fe09ce04dc
@ -398,11 +398,10 @@ extension Label {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addDefaultAttributes(range: NSRange, string: NSAttributedString?) {
|
func addDefaultAttributes(range: NSRange, string: NSMutableAttributedString?) {
|
||||||
|
|
||||||
guard let string = string else { return }
|
guard let string = string else { return }
|
||||||
let mutableAttributedString = NSMutableAttributedString(attributedString: string)
|
string.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
|
||||||
mutableAttributedString.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func setDefaultAttributes(range: NSRange) {
|
fileprivate func setDefaultAttributes(range: NSRange) {
|
||||||
@ -410,8 +409,7 @@ extension Label {
|
|||||||
guard let attributedText = attributedText else { return }
|
guard let attributedText = attributedText else { return }
|
||||||
|
|
||||||
let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText)
|
let mutableAttributedString = NSMutableAttributedString(attributedString: attributedText)
|
||||||
mutableAttributedString.addAttributes([NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue], range: range)
|
addDefaultAttributes(range: range, string: mutableAttributedString)
|
||||||
|
|
||||||
self.attributedText = mutableAttributedString
|
self.attributedText = mutableAttributedString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user