Browse Source

Display Icon in Menu Bar

Thomas Buck 8 years ago
parent
commit
9eddc1201b

+ 4
- 0
CaseLights/AppDelegate.h View File

10
 
10
 
11
 @interface AppDelegate : NSObject <NSApplicationDelegate>
11
 @interface AppDelegate : NSObject <NSApplicationDelegate>
12
 
12
 
13
+@property (weak) IBOutlet NSMenu *statusMenu;
14
+
15
+@property (strong) NSStatusItem *statusItem;
16
+@property (strong) NSImage *statusImage;
13
 
17
 
14
 @end
18
 @end
15
 
19
 

+ 8
- 2
CaseLights/AppDelegate.m View File

10
 
10
 
11
 @interface AppDelegate ()
11
 @interface AppDelegate ()
12
 
12
 
13
-@property (weak) IBOutlet NSWindow *window;
14
 @end
13
 @end
15
 
14
 
16
 @implementation AppDelegate
15
 @implementation AppDelegate
17
 
16
 
17
+@synthesize statusMenu, statusItem, statusImage;
18
+
18
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
19
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
19
-    // Insert code here to initialize your application
20
+    statusImage = [NSImage imageNamed:@"MenuIcon"];
21
+    [statusImage setTemplate:YES];
22
+    
23
+    statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
24
+    [statusItem setImage:statusImage];
25
+    [statusItem setMenu:statusMenu];
20
 }
26
 }
21
 
27
 
22
 - (void)applicationWillTerminate:(NSNotification *)aNotification {
28
 - (void)applicationWillTerminate:(NSNotification *)aNotification {

BIN
CaseLights/Assets.xcassets/MenuIcon.imageset/icon_big.png View File


BIN
CaseLights/Assets.xcassets/MenuIcon.imageset/icon_small.png View File


BIN
CaseLights/Assets.xcassets/MenuIcon.imageset/icon_small_2x.png View File


+ 5
- 1
CaseLights/Base.lproj/MainMenu.xib View File

12
         </customObject>
12
         </customObject>
13
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
13
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
14
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
15
-        <customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
15
+        <customObject id="Voe-Tx-rLC" customClass="AppDelegate">
16
+            <connections>
17
+                <outlet property="statusMenu" destination="g7M-LS-DgA" id="txO-T1-8yD"/>
18
+            </connections>
19
+        </customObject>
16
         <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
20
         <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
17
         <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
21
         <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
18
             <items>
22
             <items>

+ 1
- 1
CaseLights/Info.plist View File

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>1</string>
24
+	<string>21</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

Loading…
Cancel
Save