In my SwiftUI app, I have string names that are the name of an SF Symbol Image, or Images stored in the asset catalog.
I would like to create a view that first tries to display the image as an SF symbol image and if an SF Symbol Image with that name doesn't exist to display an Image from my asset catalog instead.
struct ImagePresenter: View {
let name: String = "test"
var body: some View {
Group {
if Image(systemName: name) == nil {
Image(name)
} else {
Image(systemName: name)
}
}
}
}