Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/V8tr/AsyncImage
Asynchronous Image Loading from URL in SwiftUI
https://github.com/V8tr/AsyncImage
combine image load-image-asynchronously load-image-url swift swiftui uiimage uiimageview
Last synced: 3 months ago
JSON representation
Asynchronous Image Loading from URL in SwiftUI
- Host: GitHub
- URL: https://github.com/V8tr/AsyncImage
- Owner: V8tr
- License: unlicense
- Created: 2020-02-13T15:46:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-08T17:02:04.000Z (almost 4 years ago)
- Last Synced: 2024-07-19T03:48:48.434Z (4 months ago)
- Topics: combine, image, load-image-asynchronously, load-image-url, swift, swiftui, uiimage, uiimageview
- Language: Swift
- Homepage: https://www.vadimbulavin.com/
- Size: 2.54 MB
- Stars: 273
- Watchers: 10
- Forks: 35
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Article related to this project
- [Asynchronous Image Loading from URL in SwiftUI](https://www.vadimbulavin.com/asynchronous-swiftui-image-loading-from-url-with-combine-and-swift/).
---
# AsyncImage
The project demonstrates how to load images asynchronously in SwiftUI.
Usage:
```swift
// Image URLs to load
let posters = [
"https://image.tmdb.org/t/p/original/pThyQovXQrw2m0s9x82twj48Jq4.jpg",
"https://image.tmdb.org/t/p/original/vqzNJRH4YyquRiWxCCOH0aXggHI.jpg",
"https://image.tmdb.org/t/p/original/6ApDtO7xaWAfPqfi2IARXIzj8QS.jpg",
"https://image.tmdb.org/t/p/original/7GsM4mtM0worCtIVeiQt28HieeN.jpg"
].map { URL(string: $0)! }struct ContentView: View {
var body: some View {
List(posters, id: \.self) { url in
AsyncImage(
url: url,
placeholder: { Text("Loading ...") },
image: { Image(uiImage: $0).resizable() }
)
.frame(idealHeight: UIScreen.main.bounds.width / 2 * 3) // 2:3 aspect ratio
}
}
}
```Result: