SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.16k stars 223 forks source link

GIF with transparent background #128

Closed Sinderella closed 4 years ago

Sinderella commented 4 years ago

Hello,

I am quite new to Swift, so I am not sure if this is the right place to ask.

I created a window with transparent background and insert a GIF with transparent background. This is what I have.

// window
        window.isOpaque = false
        window.backgroundColor = NSColor(red: 0, green: 0, blue: 0, alpha: 0)
        window.level = .floating

// view
struct ContentView: View {
    var body: some View {
        AnimatedImage(name: "unnamed.gif")
            .resizable().scaledToFit()
    }
}

image

I am not sure why the background has some sort of shadow or an afterimage where the arrows are pointing at. Is this something to do with the window property or the library?

I took the image from https://cuttyanimalss.blogspot.com/2020/01/animated-dog-gif-transparent.html.

Thank you!

dreampiggy commented 4 years ago

Check your SDWebImage version ? Does you use SDWebImage before 5.8.3 and run on iOS 14 devices ? Which contains bug on UIImageView rendering.

Or, try same URL with WebImage view instead of AnimatedImage. Note that WebImage supports animation as well, they exist for different use cases.

dreampiggy commented 4 years ago

MacOS ? Provide your test enviornment, like macOS version, SDWebImage version.

And please, use same code to run on iOS simulator. UIKit and AppKit behaves different on UIImageView/NSImageView. But I didn't have check and tested on macOS 11 Big Sur. Need someone to test new compatibility.

Sinderella commented 4 years ago

Yep, this is on macOS, version 10.15.6 (Catalina).

I used it to create a desktop application on macOS, I justed tried with animating WebImage but got the same result.

I just noticed there's some shadow behind the image, disabling it solves the issue.

window.hasShadow = false

Sorry for the trouble!