Skip to content

Instantly share code, notes, and snippets.

@taishi41228
Created March 5, 2013 00:44
Show Gist options
  • Save taishi41228/5087070 to your computer and use it in GitHub Desktop.
Save taishi41228/5087070 to your computer and use it in GitHub Desktop.
ステータスメニューの表示 ref: http://qiita.com/items/f79e27ddfbe3251669ef
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@end
#import "AppDelegate.h"
@interface AppDelegate () // クラスエクステンション?
@property (weak) IBOutlet NSMenu *statusMenu;
@end
@implementation AppDelegate{
NSStatusItem* _statusItem; // ステータスバーに表示されるアイテム
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self setupStatusItem]; // setupStatusItemメソッドの実行
}
- (void)setupStatusItem
{
NSStatusBar *systemStatusBar = [NSStatusBar systemStatusBar]; // ステータスバー
_statusItem = [systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
[_statusItem setHighlightMode:YES]; // ステータスバーに表示されるメニュー
[_statusItem setTitle:@"StatusBarApp"]; // ステータスバーに表示されるメニューのタイトル
[_statusItem setImage:[NSImage imageNamed:@"StatusBarIconTemplate"]]; // ステータスバーに表示されるメニューのアイコン画像
[_statusItem setMenu:[self statusMenu]]; // メニューをセットする
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment