Skip to content

Instantly share code, notes, and snippets.

@novinfard
Created April 21, 2021 17:58
Show Gist options
  • Save novinfard/76e975e307ce60535b9f9626c529cb29 to your computer and use it in GitHub Desktop.
Save novinfard/76e975e307ce60535b9f9626c529cb29 to your computer and use it in GitHub Desktop.
URLImage Example
// Package is available at
// https://github.com/dmytro-anokhin/url-image
import URLImage
struct URLOptionalImage: View {
var imageUrlString: String?
var body: some View {
if let urlString = imageUrlString,
let url = URL(string: urlString) {
URLImage(url: url) { image in
image
.resizable()
.aspectRatio(contentMode: .fit)
}.asAnyView()
} else {
EmptyView().asAnyView()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment