是否可以将NSStatusItem添加到NSStatusBar中的特定位置? [英] Is it possible to add a NSStatusItem to a specific position in NSStatusBar?

查看:232
本文介绍了是否可以将NSStatusItem添加到NSStatusBar中的特定位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];将statusItem添加到OSX上的systemStatusBar.然后,statusItem出现在systemStatusBar的最左侧位置.我想知道是否有办法将这样的项目添加到特定的索引中,例如在系统时钟的左侧?

I use self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; to add an statusItem to the systemStatusBar on OSX. The statusItem then appears on the left-most position in the systemStatusBar. I was wondering if there is a way to add such an item to a specific index e.g. on the left side of the system clock?

推荐答案

是,不是.您可以使用私有API指定priority来添加NSStatusItem.我为NSStatusBar开发了一个很小的类别( NSStatusBar + MISSINGOrder )女巫为此提供了简单的方法:

Yes and no. Using private API you can specify priority for adding NSStatusItem. I have developed a tiny category for NSStatusBar (NSStatusBar+MISSINGOrder) witch provides simple method for this:

NSStatusItem *statusItem =
    [systemStatusBar statusItemWithLength:NSVariableStatusItemLength
                               positioned:NSStatusBarItemOrderingModeAfter
                               relativeTo:NSStatusBarItemPriorityNotificationCenter];

您可以在内部查找实施细节.

这篇关于是否可以将NSStatusItem添加到NSStatusBar中的特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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