Skip to content
Integration of SDWebImage Asynchronous image loading and SwiftUI framework
Swift Ruby Objective-C
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swiftpm/xcode/package.xcworkspace Add Swift Package Manager support Aug 9, 2019
Example
SDWebImageSwiftUI.xcodeproj
SDWebImageSwiftUI Update to the latest Xcode 11-beta5 syntax of SwiftUI Aug 9, 2019
.gitignore Update the Travis-CI script Aug 9, 2019
.travis.yml Fix the Travis-CI script Aug 9, 2019
Cartfile Add the Xcode project to support Carthage. Fix the build issue on mac… Aug 9, 2019
Cartfile.resolved Add the Xcode project to support Carthage. Fix the build issue on mac… Aug 9, 2019
LICENSE Initial commit Aug 7, 2019
Package.resolved Add Swift Package Manager support Aug 9, 2019
Package.swift Add Swift Package Manager support Aug 9, 2019
README.md Update readme to fix some typos Aug 9, 2019
SDWebImageSwiftUI.podspec
_Pods.xcodeproj Initial commit Aug 7, 2019

README.md

SDWebImageSwiftUI

CI Status Version License Platform Carthage compatible SwiftPM compatible

What's for

This is an experimental project for SDWebImage.

It aims to ensure the following function available for users and try to do some experiments for Swift platform.

  • Swift Package Manager integration
  • SwiftUI compatibility
  • Swift source code compatibility

Note we do not guarantee the public API stable for current status. Since Xcode 11 is not get released and SwiftUI is a new platform for us.

Requirements

  • Xcode 11+
  • iOS 13+
  • macOS 10.15+
  • tvOS 13+
  • watchOS 6+

Installation

CocoaPods

SDWebImageSwiftUI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SDWebImageSwiftUI'

Carthage

SDWebImageSwiftUI is available through Carthage.

github "SDWebImage/SDWebImageSwiftUI"

Swift Package Manager

SDWebImageSwiftUI is available through Swift Package Manager.

let package = Package(
    dependencies: [
        .package(url: "https://github.com/SDWebImage/SDWebImageSwiftUI.git", from: "0.1")
    ],
)

Usage

  • Using WebImage to load network image

It supports the placeholder and detail options control for image loading as SDWebImage.

var body: some View {
    WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic")!)
        .scaledToFit()
        .frame(width: 300, height: 300, alignment: .center)
}
  • Using AnimatedImage to play animation
var body: some View {
    AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif")!)
    AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
}

It supports both image url or image data for animated image format. Which use the SDWebImage's Animated ImageView for internal implementation.

Demo

To run the example using SwiftUI, following the steps:

cd Example
pod install

Then open the Xcode Workspace to run the demo application.

Screenshot

Author

DreamPiggy

License

SDWebImageSwiftUI is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.