From 2247e529c0874f7960f58310bf4643a62cc26029 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 26 Aug 2022 14:20:24 -0500 Subject: [PATCH] coverted to colors Signed-off-by: Matt Bruce --- VDS/Components/Label/Attributes/LabelAttributeColor.swift | 6 +++--- VDS/Components/Label/Attributes/LabelAttributeFont.swift | 6 +++--- .../Label/Attributes/LabelAttributeUnderline.swift | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VDS/Components/Label/Attributes/LabelAttributeColor.swift b/VDS/Components/Label/Attributes/LabelAttributeColor.swift index 59f9727f..977d3c6e 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeColor.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeColor.swift @@ -14,11 +14,11 @@ public struct LabelAttributeColor: LabelAttributeModel { //-------------------------------------------------- public var location: Int public var length: Int - public var color: String + @CodableColor public var color: UIColor //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, color: String = "#000000") { + public init(location: Int, length: Int, color: UIColor = .black) { self.location = location self.length = length self.color = color @@ -26,6 +26,6 @@ public struct LabelAttributeColor: LabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { attributedString.removeAttribute(.foregroundColor, range: range) - attributedString.addAttribute(.foregroundColor, value: UIColor(hexString: color), range: range) + attributedString.addAttribute(.foregroundColor, value: color, range: range) } } diff --git a/VDS/Components/Label/Attributes/LabelAttributeFont.swift b/VDS/Components/Label/Attributes/LabelAttributeFont.swift index 80e773ad..c1dccc53 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeFont.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeFont.swift @@ -15,11 +15,11 @@ public struct LabelAttributeFont: LabelAttributeModel { public var location: Int public var length: Int public var style: TypographicalStyle - public var color: String + @CodableColor public var color: UIColor //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(location: Int, length: Int, style: TypographicalStyle, color: String = "#000000") { + public init(location: Int, length: Int, style: TypographicalStyle, color: UIColor = .black) { self.location = location self.length = length self.style = style @@ -31,6 +31,6 @@ public struct LabelAttributeFont: LabelAttributeModel { attributedString.removeAttribute(.font, range: range) attributedString.removeAttribute(.foregroundColor, range: range) attributedString.addAttribute(.font, value: style.font, range: range) - attributedString.addAttribute(.foregroundColor, value: UIColor(hexString: color), range: range) + attributedString.addAttribute(.foregroundColor, value: color, range: range) } } diff --git a/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift b/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift index f904d52b..83a19a37 100644 --- a/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift +++ b/VDS/Components/Label/Attributes/LabelAttributeUnderline.swift @@ -11,7 +11,7 @@ import UIKit public struct LabelAttributeUnderline: LabelAttributeModel { public var location: Int public var length: Int - public var color: String? + @OptionalCodableColor public var color: UIColor? public var style: UnderlineStyle = .single public var pattern: UnderlineStyle.Pattern? @@ -23,7 +23,7 @@ public struct LabelAttributeUnderline: LabelAttributeModel { } } - public init(location: Int, length: Int, style: UnderlineStyle = .single, color: String? = nil, pattern: UnderlineStyle.Pattern? = nil) { + public init(location: Int, length: Int, style: UnderlineStyle = .single, color: UIColor = .black, pattern: UnderlineStyle.Pattern? = nil) { self.location = location self.length = length self.color = color @@ -34,7 +34,7 @@ public struct LabelAttributeUnderline: LabelAttributeModel { public func setAttribute(on attributedString: NSMutableAttributedString) { attributedString.addAttribute(.underlineStyle, value: underlineValue.rawValue, range: range) if let color = color { - attributedString.addAttribute(.underlineColor, value: UIColor(hexString: color), range: range) + attributedString.addAttribute(.underlineColor, value: color, range: range) } } }