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) }