Skip to content

Commit 3ea6e12

Browse files
committed
Update the readme with some typo fix and code sample
1 parent ee7445a commit 3ea6e12

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ var body: some View {
104104
.resizable() // Actually this is not needed unlike SwiftUI.Image
105105
.indicator(SDWebImageActivityIndicator.medium) // Activity Indicator
106106
.transition(.fade) // Fade Transition
107-
.scaledToFit()
107+
.scaledToFit() // Attention to call it on AnimatedImage, but not `some View` after View Modifier
108+
108109
// Data
109110
AnimatedImage(data: try! Data(contentsOf: URL(fileURLWithPath: "/tmp/foo.webp")))
110111
.customLoopCount(1)
112+
111113
// Bundle (not Asset Catalog)
112114
AnimatedImage(name: "animation1", isAnimating: $isAnimating)) // Animation control binding
113115
.maxBufferSize(.max)
@@ -119,13 +121,13 @@ Note: `AnimatedImage` supports both image url or image data for animated image f
119121

120122
Note: From v0.4.0, `AnimatedImage` supports watchOS as well. However, it's not backed by SDWebImage's [Animated ImageView](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#animated-image-50) like iOS/tvOS/macOS. It use some tricks and hacks because of the limitation on current Apple's API. It also use Image/IO decoding system, which means it supports GIF and APNG format only, but not external format like WebP.
121123

122-
## Which View to choose
124+
### Which View to choose
123125

124-
Why we have two different View types here, is because of current SwiftUI limitation, and we want to beyond that, to provide best solution for both usage.
126+
Why we have two different View types here, is because of current SwiftUI limit. But we're aimed to provide best solution for all use cases.
125127

126-
If you don't need animated image, prefer to use `WebImage` firstly. Which behaves the seamless as built-in SwiftUI View. It SwiftUI works, it works.
128+
If you don't need animated image, prefer to use `WebImage` firstly. Which behaves the seamless as built-in SwiftUI View. If SwiftUI works, it works.
127129

128-
If you need animated image, `AnimatedImage` is the only one to choose. Remember it supports static image as well, you don't need to check the url format, just use as it.
130+
If you need animated image, `AnimatedImage` is the one to choose. Remember it supports static image as well, you don't need to check the format, just use as it.
129131

130132
But, because `AnimatedImage` use `UIViewRepresentable` and driven by UIKit, currently there may be some small incompatible issues between UIKit and SwiftUI layout and animation system. We try our best to match SwiftUI behavior, and provide the same API as `WebImage`, which make it easy to switch between these two types.
131133

0 commit comments

Comments
 (0)