Skip to content

Repository files navigation

AsyncResizableImage

A SwiftUI view that asynchronously downloads, cache and optionally resizes an image from a URL

Features

  • Asynchronously fetches an image from a URL
  • Optionally resizes the image to a given size
  • Caches the downloaded image
  • Fully customizable placeholder and image rendering

Installation

Add the following to your Package.swift dependencies:

.package(url:"https://github.com/AnthonyBY/AsyncResizableImage.git", from:"1.0.0")

Then add "AsyncResizableImage" to your target dependencies:

.target(
name:"YourTarget",
dependencies:["AsyncResizableImage"])

Usage

import AsyncResizableImage
import SwiftUI
structContentView:View{varbody:someView{AsyncResizableImage(
url:URL(string:"https://example.com/image.jpg"),
targetSize:CGSize(width:200, height:200),
content:{ image in
image
.resizable().aspectRatio(contentMode:.fit)},
placeholder:{ProgressView()})}}

Or you can just copy the file AsyncResizableImage to your project.

Enjoy

License

MIT License. See LICENSE for details.

About

SwiftUI Async Cached Resizable Image

Resources

Stars

19 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages