SDWebImageSwiftUI/README.md

83 lines
2.1 KiB
Markdown
Raw Normal View History

2019-08-07 18:10:05 +08:00
# SDWebImageSwiftUI
[![CI Status](https://img.shields.io/travis/lizhuoli1126@126.com/SDWebImageSwiftUI.svg?style=flat)](https://travis-ci.org/lizhuoli1126@126.com/SDWebImageSwiftUI)
[![Version](https://img.shields.io/cocoapods/v/SDWebImageSwiftUI.svg?style=flat)](https://cocoapods.org/pods/SDWebImageSwiftUI)
[![License](https://img.shields.io/cocoapods/l/SDWebImageSwiftUI.svg?style=flat)](https://cocoapods.org/pods/SDWebImageSwiftUI)
[![Platform](https://img.shields.io/cocoapods/p/SDWebImageSwiftUI.svg?style=flat)](https://cocoapods.org/pods/SDWebImageSwiftUI)
## What's for
2019-08-07 18:10:05 +08:00
This is an experimental project for [SDWebImage](https://github.com/SDWebImage/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
2019-08-07 18:10:05 +08:00
## Requirements
+ Xcode 11+
+ iOS 13+
+ macOS 10.15+
+ tvOS 13+
+ watchOS 6+
2019-08-07 18:10:05 +08:00
## Installation
SDWebImageSwiftUI is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'SDWebImageSwiftUI'
```
## Usage
+ Using `WebImage` to load network image
It supports the placeholder and detail options control for image loading as SDWebImage.
```swift
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
```swift
var body: some View {
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif")!)
}
```
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
![](Example/Screenshot/1.jpg)
2019-08-07 18:10:05 +08:00
## Author
DreamPiggy
2019-08-07 18:10:05 +08:00
## License
SDWebImageSwiftUI is available under the MIT license. See the LICENSE file for more info.