Search code examples
macoscocoanswindownsstatusitem

How to animate closing NSWindow to NSStatusItem?


When you minimize an NSWindow you get a nice animation to the Dock. How to achieve a similar animation for "minimizing" to an NSStatusItem in the menu bar?

I have it set up where the NSStatusItem appears when you close the NSWindow but there is no animation.

I've tried animating the window frame but due to various layout contraints it has a minimum size that gets in the way.


Solution

  • To animate the whole NSWindow is not the right way and will result in a rubbish looking animation. I would suggest to capture a snapshot of the window and adding it to a transparent full screen window to animate layer of the image view. This way its fare more smooth. To get an idea how it could be implemented please take a look at this project on git.

    Hope this will help.