vds_ios/VDS/Extensions/UIImage+Helper.swift
Matt Bruce 42dccb4780 add image helper
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-03-12 09:55:02 -05:00

27 lines
890 B
Swift

//
// UIImage+Icon.swift
// VDS
//
// Created by Matt Bruce on 3/11/24.
//
import Foundation
import UIKit
extension UIImage {
/// UIImage helper for finding images based on the Icon.Name which uses the internal BundleManager.
/// - Parameters:
/// - name: RawRepresentable.
/// - color: Color to Tint the image with
/// - renderingMode: UIImage Rendering mode.
/// - Returns: UIImage for this proecess
public static func image<T: RawRepresentable>(representing representable: T, color: UIColor? = nil, renderingMode: UIImage.RenderingMode = .alwaysOriginal) -> UIImage? where T.RawValue == String {
guard let image = BundleManager.shared.image(for: representable.rawValue) else { return nil }
guard let color else { return image }
return image.withTintColor(color, renderingMode: renderingMode)
}
}