From cde93a1374ebae486cbc8c437010f090cb5f1ef5 Mon Sep 17 00:00:00 2001 From: Luke Zhao Date: Tue, 30 Apr 2024 12:09:55 -0700 Subject: [PATCH] add ImageResource initialization --- Sources/UIComponent/Components/View/Image.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/UIComponent/Components/View/Image.swift b/Sources/UIComponent/Components/View/Image.swift index db97797b..4d66b227 100644 --- a/Sources/UIComponent/Components/View/Image.swift +++ b/Sources/UIComponent/Components/View/Image.swift @@ -25,6 +25,13 @@ public struct Image: Component { } + /// Initializes an `Image` component with an `ImageResource`. + /// - Parameter resource: The `ImageResource` to load the image from. + @available(iOS 17.0, *) + public init(_ resource: ImageResource) { + self.init(UIImage(resource: resource)) + } + /// Initializes an `Image` component with the name of a system image (SFSymbol). /// - Parameters: /// - systemName: The name of the system image to load.