如何使用不确定状态指示器作为 NSStatusItem 的图像?
我有一个 NSStatusItem 应用程序。
它有几种不同的模式,每种模式都需要启动外部进程,在此期间图标只是突出显示,并且似乎被冻结。
我想使用 -setImage:
方法(或合理的传真)来显示类似于 Web 应用程序和整个 OS X 中常见的“旋转器”的内容。
是否有任何本机方法可以完成这个(例如 NSProgressIndicator
的某个实例?)或者我必须通过循环浏览一组图像来手动显示动画?
无论哪种情况,我将如何实施?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使其具有动画效果(而不仅仅是静态图像),您可能需要使用
-setView:
并给它一个自定义视图(然后它会自行动画)。您也许可以使用适当配置的标准NSProgressIndicator
(即设置为NSProgressIndicatorSpinningStyle
样式等)作为“自定义视图”。但是,如果 NSProgressIndicator 标准尺寸效果不佳,那么您可以查看我的 YRKSpinningProgressIndicator (BSD 许可),它是旋转 NSProgressIndicator 的克隆,可以设置为任意大小和颜色。
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 standardNSProgressIndicator
(i.e. set toNSProgressIndicatorSpinningStyle
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.