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?
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];
You can look inside for implementation details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With