vds_ios/VDS/Components/Label/Attributes/LabelAttributeFont.swift
Matt Bruce 378802eb5e updated to equalSelf
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-09-15 16:50:21 -05:00

45 lines
1.4 KiB
Swift

//
// LabelAttributeFont.swift
// VDS
//
// Created by Matt Bruce on 8/3/22.
//
import Foundation
import UIKit
public struct LabelAttributeFont: LabelAttributeModel {
public func isEqualSelf(_ equatable: LabelAttributeFont) -> Bool {
return id == equatable.id
&& range == equatable.range
&& color == equatable.color
&& style == equatable.style
}
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var id = UUID()
public var location: Int
public var length: Int
public var style: TypographicalStyle
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)
}
}