vds_ios/VDS/Components/Label/Attributes/LabelAttributeFont.swift
Matt Bruce 2247e529c0 coverted to colors
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-08-30 14:44:01 -05:00

37 lines
1.2 KiB
Swift

//
// LabelAttributeFont.swift
// VDS
//
// Created by Matt Bruce on 8/3/22.
//
import Foundation
import UIKit
public struct LabelAttributeFont: LabelAttributeModel {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var location: Int
public var length: Int
public var style: TypographicalStyle
@CodableColor public var color: UIColor
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(location: Int, length: Int, style: TypographicalStyle, color: UIColor = .black) {
self.location = location
self.length = length
self.style = style
self.color = color
}
public func setAttribute(on attributedString: NSMutableAttributedString) {
attributedString.removeAttribute(.font, range: range)
attributedString.removeAttribute(.foregroundColor, range: range)
attributedString.addAttribute(.font, value: style.font, range: range)
attributedString.addAttribute(.foregroundColor, value: color, range: range)
}
}