开发者

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

开发者 https://www.devze.com 2022-12-27 22:26 出处:网络
I have an application that is an NSStatusItem. It has a few different modes, each of which require an external pr开发者_开发技巧ocess to be launched, during which the icon is simply highlighted, and

I have an application that is an NSStatusItem.

It has a few different modes, each of which require an external pr开发者_开发技巧ocess 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号