How do I use an indeterminate status indicator as the image for an NSStatusItem?

核能气质少年 提交于 2019-12-07 09:21:03

问题


I have an application that is an NSStatusItem.

It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen.

I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X.

Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator?) or must I manually display an animation by cycling through a set of images?

In either case, how would I implement?


回答1:


In order to have it be animated (and not just a static image), you'll probably need to use -setView: and give it a custom view (which then animates itself). You might be able to get away with using a suitably-configured standard NSProgressIndicator (i.e. set to NSProgressIndicatorSpinningStyle style, etc.) as that "custom view".

But, if the NSProgressIndicator standard sizes don't work well, then you can check out my YRKSpinningProgressIndicator (BSD-licensed), which is a clone of the spinning NSProgressIndicator that can be set to arbitrary size and colors.



来源:https://stackoverflow.com/questions/2710031/how-do-i-use-an-indeterminate-status-indicator-as-the-image-for-an-nsstatusitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!