From 9aad50fb0b5b7b929af27008301b97fd7a8865f4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 26 Jan 2023 15:16:56 -0600 Subject: [PATCH] updated for textcolor Signed-off-by: Matt Bruce --- .../Label/Attributes/TextStyleLabelAttribute.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift index de40e02c..94947472 100644 --- a/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift +++ b/VDS/Components/Label/Attributes/TextStyleLabelAttribute.swift @@ -27,14 +27,14 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { public var location: Int public var length: Int public var textStyle: TextStyle - public var textColor: UIColor + public var textColor: UIColor? public var textPosition: TextPosition public var lineBreakMode: NSLineBreakMode //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor = .black, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { + public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) { self.location = location self.length = length self.textStyle = textStyle @@ -45,9 +45,11 @@ public struct TextStyleLabelAttribute: LabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { attributedString.removeAttribute(.font, range: range) - attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttribute(.font, value: textStyle.font, range: range) - attributedString.addAttribute(.foregroundColor, value: textColor, range: range) + if let textColor { + attributedString.removeAttribute(.foregroundColor, range: range) + attributedString.addAttribute(.foregroundColor, value: textColor, range: range) + } setStyleAttributes(attributedString) }