Skip to content

A SwiftUI view for asynchronously loading and caching images from a URL, compatible with iOS 13+.

License

Notifications You must be signed in to change notification settings

silkodenis/swiftui-async-cached-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

License

AsyncCachedImage

AsyncCachedImage is a SwiftUI view that asynchronously loads and caches an image from a URL, displaying a placeholder while the image is being loaded. This implementation is compatible with iOS 13 and later, providing greater flexibility and control over image loading and caching.

Features

  • Asynchronous image loading from a URL
  • Image caching using URLCache
  • Customizable content and placeholder views
  • Compatible with iOS 13 and later

Requirements

  • iOS 13+
  • Xcode 11+
  • Swift 5+

Installation

To use AsyncCachedImage in your project, simply copy the AsyncCachedImage.swift file into your project.

Usage

Here's an example of how to use AsyncCachedImage in your SwiftUI view:

import SwiftUI

struct ContentView: View {
    let imageUrl = URL(string: "https://example.com/image.jpg")

    var body: some View {
        AsyncCachedImage(url: imageUrl) { image in
            image
                .resizable()
                .aspectRatio(contentMode: .fit)
        } placeholder: {
            Text("Loading...")
        }
    }
}

License

This project is licensed under the Apache License, Version 2.0.

About

A SwiftUI view for asynchronously loading and caching images from a URL, compatible with iOS 13+.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages