37 lines
1.2 KiB
Swift
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
|
|
public var color: String
|
|
//--------------------------------------------------
|
|
// MARK: - Initializer
|
|
//--------------------------------------------------
|
|
public init(location: Int, length: Int, style: TypographicalStyle, 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)
|
|
}
|
|
}
|