@@ -301,15 +301,29 @@ public struct AnimatedImage : PlatformViewRepresentable {
301
301
// Refresh image, imageModel is the Source of Truth, switch the type
302
302
// Although we have Source of Truth, we can check the previous value, to avoid re-generate SDAnimatedImage, which is performance-cost.
303
303
if let name = imageModel. name, name != context. coordinator. imageLoading. imageName {
304
+ var image : PlatformImage ?
304
305
#if os(macOS)
305
- let image = SDAnimatedImage ( named: name, in: imageModel. bundle)
306
+ image = SDAnimatedImage ( named: name, in: imageModel. bundle)
307
+ if image == nil {
308
+ // For static image, use NSImage as defaults
309
+ let bundle = imageModel. bundle ?? . main
310
+ image = bundle. image ( forResource: name)
311
+ }
306
312
#else
307
- let image = SDAnimatedImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
313
+ image = SDAnimatedImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
314
+ if image == nil {
315
+ // For static image, use UIImage as defaults
316
+ image = PlatformImage ( named: name, in: imageModel. bundle, compatibleWith: nil )
317
+ }
308
318
#endif
309
319
context. coordinator. imageLoading. imageName = name
310
320
view. wrapped. image = image
311
321
} else if let data = imageModel. data, data != context. coordinator. imageLoading. imageData {
312
- let image = SDAnimatedImage ( data: data, scale: imageModel. scale)
322
+ var image : PlatformImage ? = SDAnimatedImage ( data: data, scale: imageModel. scale)
323
+ if image == nil {
324
+ // For static image, use UIImage as defaults
325
+ image = PlatformImage ( data: data)
326
+ }
313
327
context. coordinator. imageLoading. imageData = data
314
328
view. wrapped. image = image
315
329
} else if let url = imageModel. url {
0 commit comments