Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

CachedImage

Build License

πŸ”­ Overview

CachedImage is a SwiftUI component to asynchronously load and display an image provided by its URL.

This package is based on the AsyncImage project published by Vadim Bulavin and described in the Asynchronous Image Loading from URL in SwiftUI article.

πŸ› οΈ Usage

Quick Start

import CachedImage
let images = (0...20).map {
 "https://picsum.photos/800/600?random=\(0ドル)"
}
let imageURLs = images.map {
 URL(string: 0ドル)!
}
struct ContentView: View {
 var body: some View {
 List(imageURLs, id: \.self) { url in
 CachedImage(
 url: url,
 content: { image in
 image
 .resizable()
 .aspectRatio(contentMode: .fit)
 },
 placeholder: {
 Text("Loading ...")
 }
 )
 .scaledToFit()
 }
 }
}

Demo Program

Check the demo project provided here: Demo.

✍️ Author

Vadim Bulavin & Leonid Zolotarev

πŸ“ƒ License

CachedImage is available under the Unlicense. See the LICENSE file for more info.

About

Asynchronous Image Loading from URL in SwiftUI

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /