CatalystMenuBarStatusWindow - A method of presenting UIKit (or Catalyst-specific SwiftUI) content from the status menu area on macOS

Overview

CatalystMenuBarStatusWindow

This sample code showcases a method of presenting UIKit (or Catalyst-specific SwiftUI) content from the status menu area on macOS.

WARNING: In lieu of a public API to do this, we have to rely on swizzling. I've tried to make this as 'safe' as it can possibly be, but as with all swizzling and non-public API, please be careful of side-effects and potential breakage in future versions of the OS. This is to be considered an advanced topic for people who know what they're doing.

Realistically, all you're really doing is manually setting the size and position of an NSPopover when it's created, so the potential failure states should be fairly innocuous.

Overview

  • Uses an AppKit bridging bundle
  • Adds a status menu item
  • Clicking the status menu item fires a Notification
  • In the UIKit side of the app, the Notification receiver presents a view controller (in this case, with a SwiftUI content view) as a popover with a nil source view
  • Swizzles showRelativeToRect:ofView:preferredEdge: in AppKit to redirect the popover source view to the status menu item
  • As the popover is now 'attached' to the status menu item, it will move with it when rearranged
  • Process has been tested to work on both macOS 11 and macOS 12

Screenshots

https://hccdata.s3.amazonaws.com/gh_statusbar_uikit.jpg

You might also like...
Ambar is a macOS Menu Bar app built with SwiftUI.
Ambar is a macOS Menu Bar app built with SwiftUI.

Ambar Ambar is a macOS Menu Bar app built with SwiftUI. It is a template project which means that it can be used as a starting point for a new Menu Ba

a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

lyricsify a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

A menu bar app to change input source swiftly using shortcuts on macOS Big Sur or later.

Source Switcher A menu bar app to change input sources swiftly using shortcuts on macOS Big Sur and later. View screenshots Introduction This app uses

macOS (>11.0) Menu Bar App for WLED
macOS (11.0) Menu Bar App for WLED

wledQuickControl functions Left click on the Menubar icon will toggle the WLED device On/Off Right click on the Menubar icon: will update the icon/sli

SwiftBar - Powerful macOS menu bar customization tool
SwiftBar - Powerful macOS menu bar customization tool

SwiftBar - Powerful macOS menu bar customization tool

Barber lives in your macOS menu bar and keeps track of what needs to be updated.

Barber Barber is a macOS application to keep track of application updates easily. It lives in your menu bar, and uses homebrew to determine what's out

Control your display's brightness from the macOS menu bar. Simple and easy to use.
Control your display's brightness from the macOS menu bar. Simple and easy to use.

MonitorControl Lite Control your display's brightness from the macOS menu bar. Simple and easy to use. About MonitorControl Lite is a simplified versi

Let's put notification Messages icon on menu bar of your macOS
Let's put notification Messages icon on menu bar of your macOS

DockBar DockBar is just a simple app that show messages icon on your status bar when you have unread messages. This app is very useful for people who

Paimon's now in your macOS menu bar
Paimon's now in your macOS menu bar

PaimonMenuBar Paimon's now in your menu bar! Demo What's this? Genshin Impact has got a complicated daily system, consisting of: 4 Daily commisions. 5

Owner
Steven Troughton-Smith
Steven Troughton-Smith
This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit.

CatalystToolbarMenuButton This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit. There are ways to

Steven Troughton-Smith 24 Dec 8, 2022
🚄ℹ️ Show current train info (speed, next station, arrival time) in macOS status bar

TrainStatusInfo This macOS application shows the current train status info in the status bar when connected to the trains hotspot. It uses the "intern

Niklas 10 Jul 16, 2022
EasyMenu - SwiftUI Menu but not only button (similar to the native Menu)

EasyMenu SwiftUI Menu but not only button (similar to the native Menu) You can c

null 10 Oct 7, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
Slide-Menu - A Simple Slide Menu With Swift

Slide Menu!! Весь интерфейс создан через код

Kirill 0 Jan 8, 2022
Swift-sidebar-menu-example - Create amazing sidebar menu with animation using swift

 SWIFT SIDEBAR MENU EXAMPLE In this project I create a awesome side bar menu fo

Paolo Prodossimo Lopes 4 Jul 25, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
UIKit drop down menu, simple yet flexible and written in Swift

DropDownMenuKit DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding an

Quentin Mathé 258 Dec 27, 2022
adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

Naman Dwivedi 930 Jan 2, 2023