Created
April 21, 2021 17:58
-
-
Save novinfard/76e975e307ce60535b9f9626c529cb29 to your computer and use it in GitHub Desktop.
URLImage Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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