coverted to colors

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-26 14:20:24 -05:00
parent cd97f8b997
commit 34c85f0c48
3 changed files with 9 additions and 9 deletions

View File

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

View File

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

View File

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