Created
March 5, 2013 00:44
-
-
Save taishi41228/5087070 to your computer and use it in GitHub Desktop.
ステータスメニューの表示 ref: http://qiita.com/items/f79e27ddfbe3251669ef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface AppDelegate : NSObject <NSApplicationDelegate> | |
@property (assign) IBOutlet NSWindow *window; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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