如何使用不确定状态指示器作为NSStatusItem的图像? [英] How do I use an indeterminate status indicator as the image for an NSStatusItem?

查看:354
本文介绍了如何使用不确定状态指示器作为NSStatusItem的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序 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.

我想使用 -setImage :方法(或合理的传真)来显示在网络应用程序和OS X中常见的微调框线条。

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.

有没有任何本地方法来完成这个(例如 NSProgressIndicator ?的一些实例?)或者必须通过循环一组图像手动显示动画吗?

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?

推荐答案

动画(而不只是一个静态图像),你可能需要使用 -setView:,并给它一个自定义视图(然后动画本身)。您可以使用合适配置的标准 NSProgressIndicator (即设置为 NSProgressIndicatorSpinningStyle 样式等)。 )作为自定义视图。

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".

但是,如果NSProgressIndicator标准尺寸不能正常工作,那么你可以查看我的 YRKSpinningProgressIndicator (BSD许可),这是一个旋转NSProgressIndicator的克隆,可以设置为任意大小和颜色。

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.

这篇关于如何使用不确定状态指示器作为NSStatusItem的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆