Skip to content

Commit de29f0b

Browse files
authored
Merge pull request #165 from SDWebImage/update_webimage_defaults_animating
Update the WebImage to defaults animatable
2 parents 74d142d + 25a9b46 commit de29f0b

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ All issue reports, feature requests, contributions, and GitHub stars are welcome
5757
+ watchOS 6+
5858
+ Swift 5.1+
5959

60+
## SwiftUI 2.0 Compatibility
61+
62+
iOS 14(macOS 11) introduce the SwiftUI 2.0, which keep the most API compatible, but changes many internal behaviors, which breaks the SDWebImageSwiftUI's function.
63+
64+
From v1.6.0, we adopt SwiftUI 2.0 and iOS 14(macOS 11)'s behavior.You can use `WebImage` and `AnimatedImage` inside the new `LazyVStack`.
65+
66+
```swift
67+
var body: some View {
68+
ScrollView {
69+
LazyVStack {
70+
ForEach(urls, id: \.self) { url in
71+
AnimatedImage(url: url)
72+
}
73+
}
74+
}
75+
}
76+
```
77+
78+
Note: However, many differences behavior between iOS 13/14's is hard to fixup. Due to maintain issue, in the future v2.0.0, we will drop the iOS 13 supports and always match SwiftUI 2.0's behavior.
79+
80+
6081
## Installation
6182

6283
#### Swift Package Manager
@@ -128,9 +149,7 @@ var body: some View {
128149
}
129150
```
130151

131-
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But unlike SwiftUI's `Image` which does not support animated image or vector image, `WebImage` supports animated image as well.
132-
133-
Note: The `WebImage` animation provide common use case, so it's still recommend to use `AnimatedImage` for advanced controls like progressive animation rendering.
152+
Note: This `WebImage` using `Image` for internal implementation, which is the best compatible for SwiftUI layout and animation system. But unlike SwiftUI's `Image` which does not support animated image or vector image, `WebImage` supports animated image as well (by defaults from v1.6.0)
134153

135154
```swift
136155
@State var isAnimating: Bool = true
@@ -143,6 +162,8 @@ var body: some View {
143162
}
144163
```
145164

165+
Note: The `WebImage` animation provide common use case, so it's still recommend to use `AnimatedImage` for advanced controls like progressive animation rendering, or vector image rendering. In a word, `WebImage` can render animated image, but not always the best choice.
166+
146167
### Using `AnimatedImage` to play animation
147168

148169
- [x] Supports network image as well as local data and bundle image

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct WebImage : View {
3434
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
3535
/// - Parameter context: A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
3636
public init(url: URL?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]? = nil) {
37-
self.init(url: url, options: options, context: context, isAnimating: .constant(false))
37+
self.init(url: url, options: options, context: context, isAnimating: .constant(true))
3838
}
3939

4040
/// Create a web image with url, placeholder, custom options and context. Optional can support animated image using Binding.

0 commit comments

Comments
 (0)