vds_ios/VDS/Components/Label/Attributes/SystemImageLabelAttribute.swift
Matt Bruce 02a3bd9e78 refactored names of XXXLabelAttribute
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-10-04 15:08:03 -05:00

33 lines
954 B
Swift

//
// LabelSystemImageLabelAttribute.swift
// VDS
//
// Created by Matt Bruce on 10/4/22.
//
import Foundation
import UIKit
public struct SystemImageLabelAttribute: AttachmentLabelAttributeModel {
public var id = UUID()
public var location: Int
public var length: Int
public var imageName: String
public var frame: CGRect
public var tintColor: UIColor
public static func == (lhs: SystemImageLabelAttribute, rhs: SystemImageLabelAttribute) -> Bool {
lhs.isEqual(rhs)
}
public func isEqual(_ equatable: SystemImageLabelAttribute) -> Bool {
return id == equatable.id && range == equatable.range && imageName == equatable.imageName
}
public func getAttachment() throws -> NSTextAttachment {
let attachment = NSTextAttachment()
attachment.image = UIImage(systemName: imageName)?.withTintColor(tintColor)
attachment.bounds = frame
return attachment
}
}