98dcd2d619 | ||
---|---|---|
.swiftpm/xcode/package.xcworkspace | ||
Example | ||
SDWebImageSwiftUI | ||
SDWebImageSwiftUI.xcodeproj | ||
.gitignore | ||
.travis.yml | ||
Cartfile | ||
Cartfile.resolved | ||
LICENSE | ||
Package.resolved | ||
Package.swift | ||
README.md | ||
SDWebImageSwiftUI.podspec | ||
_Pods.xcodeproj |
README.md
SDWebImageSwiftUI
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 experiences for Swift platform.
- Swift Package Manager integration
- SwiftUI compatibility
- Swift source code compatibility
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 "dreampiggy/SDWebImageSwiftUI"
Swift Package Manager
SDWebImageSwiftUI is available through Swift Package Manager.
let package = Package(
dependencies: [
.package(url: "https://github.com/dreampiggy/SDWebImageSwiftUI.git", .branch("master"))
],
)
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.
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.