Browse Source

Display Icon in Menu Bar

Thomas Buck 5 years ago
parent
commit
9eddc1201b

+ 4
- 0
CaseLights/AppDelegate.h View File

@@ -10,6 +10,10 @@
10 10
 
11 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 18
 @end
15 19
 

+ 8
- 2
CaseLights/AppDelegate.m View File

@@ -10,13 +10,19 @@
10 10
 
11 11
 @interface AppDelegate ()
12 12
 
13
-@property (weak) IBOutlet NSWindow *window;
14 13
 @end
15 14
 
16 15
 @implementation AppDelegate
17 16
 
17
+@synthesize statusMenu, statusItem, statusImage;
18
+
18 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 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,7 +12,11 @@
12 12
         </customObject>
13 13
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14 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 20
         <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
17 21
         <menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
18 22
             <items>

+ 1
- 1
CaseLights/Info.plist View File

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

Loading…
Cancel
Save