I am trying to load and display a gif file inside a NSImageView but nothing appears when I run the project.
I have try to link the gif file with NSImageView using url, data or named, but it does not work.
func applicationDidFinishLaunching(_ aNotification: Notification)
{
let url = Bundle.main.url(forResource: "RSynchro-Gif", withExtension: "gif")!
let data = try! Data(contentsOf: url)
gifBoutton.image = NSImage(data: data)
}
or
func applicationDidFinishLaunching(_ aNotification: Notification)
{
let url = Bundle.main.url(forResource: "RSynchro-Gif", withExtension: "gif")!
gifBoutton.image = try! NSImage(data: Data(contentsOf: url))
}
or
func applicationDidFinishLaunching(_ aNotification: Notification)
{
let icon = NSImage(named: NSImage.Name(rawValue: "RSynchro-Gif"))
imageGif.image = icon
imageGif.animates = true
}
None of them works but if I replace the .gif file with a .png, it works. Anyone to show me the right way? Thanks.