Created
August 26, 2023 08:44
-
-
Save jdamner/14c01237c31e76c5bf2433b5d4f22df5 to your computer and use it in GitHub Desktop.
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
class Example { | |
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) | |
Let menubarStringValue = "example" | |
func updateValue() { | |
if #available(OSX 10.15, *){ | |
let attributes = [NSAttributedString.Key.font: NSFont.monospacedSystemFont(ofSize: NSFont.systemFontSize(for: self.statusItem.button!.controlSize), weight: NSFont.Weight.medium)] | |
let attrString = NSAttributedString(string: (self.menubarStringValue), attributes: attributes) | |
} else { | |
let attributes = [NSAttributedString.Key.font: NSFont(name: "Monaco", size: NSFont.systemFontSize(for:self.statusItem.button!.controlSize))] | |
let attrString = NSAttributedString(string: (self.menubarStringValue), attributes: attributes as [NSAttributedString.Key : Any]) | |
} | |
self.statusItem.button?.attributedTitle = (attrString) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment