diff --git a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift index 8d70296d..e266f15f 100644 --- a/VDS/Components/Label/Attributes/ColorLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/ColorLabelAttribute.swift @@ -19,17 +19,20 @@ public struct ColorLabelAttribute: LabelAttributeModel { public var location: Int public var length: Int public var color: UIColor + public var isForegroundColor: Bool //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, color: UIColor = .black) { + public init(location: Int, length: Int, color: UIColor = .black, isForegroundColor: Bool = true) { self.location = location self.length = length self.color = color + self.isForegroundColor = isForegroundColor } public func setAttribute(on attributedString: NSMutableAttributedString) { - attributedString.removeAttribute(.foregroundColor, range: range) - attributedString.addAttribute(.foregroundColor, value: color, range: range) + let attributeKey = isForegroundColor ? NSAttributedString.Key.foregroundColor : NSAttributedString.Key.backgroundColor + attributedString.removeAttribute(attributeKey, range: range) + attributedString.addAttribute(attributeKey, value: color, range: range) } }