Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use KFAnimatedImage on MacOS? #2149

Open
a-soll opened this issue Oct 12, 2023 · 2 comments
Open

How to use KFAnimatedImage on MacOS? #2149

a-soll opened this issue Oct 12, 2023 · 2 comments

Comments

@a-soll
Copy link

a-soll commented Oct 12, 2023

I see that KFAnimatedImage is available for MacOS 11, but it also requires UIKit to be able to be imported, which is iOS only. Am I missing something?

@onevcat
Copy link
Owner

onevcat commented Oct 27, 2023

This was marked wrongly. That class is now only for iOS and I will fix its declaration soon.

There is a medium-term plan to expand the animated image to macOS and also support other format (APNG, WebP, etc), but I almost cannot find a proper time to do it. :(

@a-soll
Copy link
Author

a-soll commented Oct 27, 2023

struct EmoteImage: NSViewRepresentable {
    var url: String
    var imageView = NSImageView()

    func makeNSView(context: Context) -> NSImageView {
        imageView.kf.setImage(with: URL(string: self.url), placeholder: NSImage(systemSymbolName: "circle.fill", accessibilityDescription: nil))
        imageView.animates = true
        return imageView
    }
    func updateNSView(_ nsView: NSImageView, context: Context) {
    }
}

it's all good, I ended up being able to wrap it with NSViewRepresentable and have animated images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants