vds_ios/VDS/Components/Label/Attributes/LabelAttributeFont.swift
Matt Bruce 5a22e6ecd0 first cut
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-08-03 17:03:59 -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: FontStyle
public var color: String
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(location: Int, length: Int, style: FontStyle, color: String = "#000000") {
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: UIColor(hexString: color), range: range)
}
}