Post

Replies

Boosts

Views

Activity

Reply to How to match Status/Menu Bar font (Date and Time)
Please see screenshot attached: I'm trying to match and align the font (timer 0:00 in the screenshot) with macOS Time/Date item on the Status Bar. On built-in display (white font) it needs baselineOffset: 0.5 to align. External display (black font) does not require such. I tried different resolutions on both 27" 4K and 14" MBP. class AppDelegate: NSObject, NSApplicationDelegate { private var statusItem: NSStatusItem! … private func updateStatusBar() { guard let button = statusItem.button else { return } let title = “0:00” DispatchQueue.main.async { let font = NSFont.systemFont(ofSize: NSFont.systemFontSize, weight: .regular) let attributes: [NSAttributedString.Key: Any] = [ .font: font, .foregroundColor: NSColor.textColor, .baselineOffset: 0.5 ] let attributedTitle = NSAttributedString(string: title, attributes: attributes) button.attributedTitle = attributedTitle } } ... } @main class App { static func main() { let app = NSApplication.shared let delegate = AppDelegate() app.delegate = delegate app.run() } }
Topic: UI Frameworks SubTopic: AppKit Tags:
Apr ’25