File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
Example/SDWebImageSwiftUIDemo
SDWebImageSwiftUI/Classes Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,24 @@ class UserSettings: ObservableObject {
1717 #endif
1818}
1919
20+ struct ContentView5 : View {
21+ let url : URL = URL ( string: " http://assets.sbnation.com/assets/2512203/dogflops.gif " ) !
22+
23+ @State private var isAnimating = false
24+
25+ var body : some View {
26+ ZStack {
27+ WebImage ( url: url, isAnimating: $isAnimating)
28+ . pausable ( false )
29+ Button {
30+ isAnimating. toggle ( )
31+ } label: {
32+ Text ( isAnimating ? " Stop " : " Start " )
33+ }
34+ }
35+ }
36+ }
37+
2038#if !os(watchOS)
2139struct ContentView4 : View {
2240 var url = URL ( string: " https://github.com/SDWebImage/SDWebImageSwiftUI/assets/97430818/72d27f90-e9d8-48d7-b144-82ada828a027 " ) !
Original file line number Diff line number Diff line change @@ -132,11 +132,11 @@ public struct WebImage<Content> : View where Content: View {
132132 if context [ . imageScaleFactor] == nil {
133133 context [ . imageScaleFactor] = scale
134134 }
135- // provide animated image class if the initialized `isAnimating` is true, user can still custom the image class if they want
136- if isAnimating . wrappedValue {
137- if context [ . animatedImageClass ] == nil {
138- context [ . animatedImageClass] = SDAnimatedImage . self
139- }
135+ // always provide animated image class to allows dynamic control
136+ // since most cases, SDAnimatedImage should be compatible with UIImage
137+ // user can still custom the image class if they want
138+ if context [ . animatedImageClass] == nil {
139+ context [ . animatedImageClass ] = SDAnimatedImage . self
140140 }
141141 let imageModel = WebImageModel ( )
142142 imageModel. url = url
You can’t perform that action at this time.
0 commit comments