问题描述
我使用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中的特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!