@@ -286,15 +286,29 @@ public struct AnimatedImage : PlatformViewRepresentable {
286286 // Refresh image, imageModel is the Source of Truth, switch the type
287287 // Although we have Source of Truth, we can check the previous value, to avoid re-generate SDAnimatedImage, which is performance-cost.
288288 if let name = imageModel. name, name != context. coordinator. imageLoading. imageName {
289+ var image : PlatformImage ?
289290 #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+ }
291297 #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+ }
293303 #endif
294304 context. coordinator. imageLoading. imageName = name
295305 view. wrapped. image = image
296306 } 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+ }
298312 context. coordinator. imageLoading. imageData = data
299313 view. wrapped. image = image
300314 } else if let url = imageModel. url {
0 commit comments