@@ -286,15 +286,29 @@ public struct AnimatedImage : PlatformViewRepresentable {
286
286
// Refresh image, imageModel is the Source of Truth, switch the type
287
287
// Although we have Source of Truth, we can check the previous value, to avoid re-generate SDAnimatedImage, which is performance-cost.
288
288
if let name = imageModel. name, name != context. coordinator. imageLoading. imageName {
289
+ var image : PlatformImage ?
289
290
#if os(macOS)
290
- let image = SDAnimatedImage ( named: name, in: imageModel. bundle)
291
+ image = SDAnimatedImage ( named: name, in: imageModel. bundle)
292
+ if image == nil {
293
+ // For static image, use NSImage as defaults
294
+ let bundle = imageModel. bundle ?? . main
295
+ image = bundle. image ( forResource: name)
296
+ }
291
297
#else
292
- let image = SDAnimatedImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
298
+ image = SDAnimatedImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
299
+ if image == nil {
300
+ // For static image, use UIImage as defaults
301
+ image = PlatformImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
302
+ }
293
303
#endif
294
304
context. coordinator. imageLoading. imageName = name
295
305
view. wrapped. image = image
296
306
} else if let data = imageModel. data, data != context. coordinator. imageLoading. imageData {
297
- let image = SDAnimatedImage ( data: data, scale: imageModel. scale)
307
+ var image : PlatformImage ? = SDAnimatedImage ( data: data, scale: imageModel. scale)
308
+ if image == nil {
309
+ // For static image, use UIImage as defaults
310
+ image = PlatformImage . sd_image ( with: data, scale: imageModel. scale)
311
+ }
298
312
context. coordinator. imageLoading. imageData = data
299
313
view. wrapped. image = image
300
314
} else if let url = imageModel. url {
0 commit comments