I have a menu with an NSImage showing some information, and when it gets updated I would like the new (updated) image to fade in. I know it is easy on the iPhone, but is this possible in OS X ?
You can try using this. It was written in Swift 4
let transition = CATransition() //create transition
transition.duration = 4 //set duration time in seconds
transition.type = .fade //animation type
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
self.imageView.layer?.add(transition, forKey: nil) //add animation to your imageView's layer
self.imageView.image = NSImage(named: "test_image") //set the image
I think that one of the most valuable example is ImageTransition. It's easy to understand at least for me, coming from the iOS world. http://developer.apple.com/library/mac/samplecode/ImageTransition/ImageTransition.zip
Hope it helps, Paolo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With