Merge pull request #165 from SDWebImage/update_webimage_defaults_animating
Update the WebImage to defaults animatable
This commit is contained in:
commit
de29f0b0a6
27
README.md
27
README.md
|
@ -57,6 +57,27 @@ All issue reports, feature requests, contributions, and GitHub stars are welcome
|
||||||
+ watchOS 6+
|
+ watchOS 6+
|
||||||
+ Swift 5.1+
|
+ Swift 5.1+
|
||||||
|
|
||||||
|
## SwiftUI 2.0 Compatibility
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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`.
|
||||||
|
|
||||||
|
```swift
|
||||||
|
var body: some View {
|
||||||
|
ScrollView {
|
||||||
|
LazyVStack {
|
||||||
|
ForEach(urls, id: \.self) { url in
|
||||||
|
AnimatedImage(url: url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
#### Swift Package Manager
|
#### Swift Package Manager
|
||||||
|
@ -128,9 +149,7 @@ var body: some View {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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)
|
||||||
|
|
||||||
Note: The `WebImage` animation provide common use case, so it's still recommend to use `AnimatedImage` for advanced controls like progressive animation rendering.
|
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
@State var isAnimating: Bool = true
|
@State var isAnimating: Bool = true
|
||||||
|
@ -143,6 +162,8 @@ var body: some View {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
### Using `AnimatedImage` to play animation
|
### Using `AnimatedImage` to play animation
|
||||||
|
|
||||||
- [x] Supports network image as well as local data and bundle image
|
- [x] Supports network image as well as local data and bundle image
|
||||||
|
|
|
@ -34,7 +34,7 @@ public struct WebImage : View {
|
||||||
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
|
/// - Parameter options: The options to use when downloading the image. See `SDWebImageOptions` for the possible values.
|
||||||
/// - 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.
|
/// - 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.
|
||||||
public init(url: URL?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]? = nil) {
|
public init(url: URL?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]? = nil) {
|
||||||
self.init(url: url, options: options, context: context, isAnimating: .constant(false))
|
self.init(url: url, options: options, context: context, isAnimating: .constant(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a web image with url, placeholder, custom options and context. Optional can support animated image using Binding.
|
/// Create a web image with url, placeholder, custom options and context. Optional can support animated image using Binding.
|
||||||
|
|
Loading…
Reference in New Issue