ensure color range
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
86c675a07f
commit
bb655eefa2
@ -34,11 +34,10 @@ public struct ColorLabelAttribute: LabelAttributeModel {
|
|||||||
var colorRange = range
|
var colorRange = range
|
||||||
if length == 0 && location == 0 {
|
if length == 0 && location == 0 {
|
||||||
colorRange = .init(location: location, length: attributedString.length)
|
colorRange = .init(location: location, length: attributedString.length)
|
||||||
if !attributedString.isValid(range: colorRange) { return }
|
|
||||||
} else {
|
|
||||||
guard isValidRange(on: attributedString) else { return }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !attributedString.isValid(range: colorRange) { return }
|
||||||
|
|
||||||
let attributeKey = isForegroundColor ? NSAttributedString.Key.foregroundColor : NSAttributedString.Key.backgroundColor
|
let attributeKey = isForegroundColor ? NSAttributedString.Key.foregroundColor : NSAttributedString.Key.backgroundColor
|
||||||
attributedString.removeAttribute(attributeKey, range: colorRange)
|
attributedString.removeAttribute(attributeKey, range: colorRange)
|
||||||
attributedString.addAttribute(attributeKey, value: color, range: colorRange)
|
attributedString.addAttribute(attributeKey, value: color, range: colorRange)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user