27 lines
890 B
Swift
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)
|
|
}
|
|
}
|