Update the readme about the success/failure/progress handle
This commit is contained in:
parent
b1940dff46
commit
7128a13c50
10
README.md
10
README.md
|
@ -63,13 +63,18 @@ let package = Package(
|
||||||
|
|
||||||
+ Using `WebImage` to load network image
|
+ Using `WebImage` to load network image
|
||||||
|
|
||||||
It supports the placeholder and detail options control for image loading as SDWebImage.
|
Supports the placeholder and detail options control for image loading as SDWebImage.
|
||||||
|
|
||||||
|
Supports the success/failure/progress changes event for custom handling.
|
||||||
|
|
||||||
Note: Unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation. This `WebImage` using `Image` for internal implementation and supports static image format only.
|
Note: Unlike `UIImageView` in UIKit, SwiftUI's `Image` does not support animation. This `WebImage` using `Image` for internal implementation and supports static image format only.
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
var body: some View {
|
var body: some View {
|
||||||
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
|
WebImage(url: URL(string: "https://nokiatech.github.io/heif/content/images/ski_jump_1440x960.heic"))
|
||||||
|
.onSuccess(perform: { (image, cacheType) in
|
||||||
|
// Success
|
||||||
|
})
|
||||||
.resizable()
|
.resizable()
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
.frame(width: 300, height: 300, alignment: .center)
|
.frame(width: 300, height: 300, alignment: .center)
|
||||||
|
@ -81,6 +86,9 @@ var body: some View {
|
||||||
```swift
|
```swift
|
||||||
var body: some View {
|
var body: some View {
|
||||||
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
|
AnimatedImage(url: URL(string: "https://raw.githubusercontent.com/liyong03/YLGIFImage/master/YLGIFImageDemo/YLGIFImageDemo/joy.gif"))
|
||||||
|
.onFailure(perform: { (error) in
|
||||||
|
// Error
|
||||||
|
})
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
|
AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
|
||||||
.scaledToFill()
|
.scaledToFill()
|
||||||
|
|
Loading…
Reference in New Issue