macOS status bar popups done right 😎
MBPopup is a macOS framework for easily adding a customizable status bar popup to your apps.
MBPopup is based on Popup by shpakovski, after it had been used in HAPU for 3+ years and incrementally improved on, and is now rewritten for Swift and improved for the Swift era.
More importantly, multiple parts have been rewritten in order to replicate the behavior of system menu bar items:
While also,
MBPopup is App Store-approved and is currently being used in the app stts:
(For more examples, check the Example project, or stts' source)
Add MBPopup via Swift Package Manager
Use MBPopup in your app:
import MBPopup
let myView = NSView(frame: CGRect(x: 0, y: 0, width: 200, height: 300))
let popupController = MBPopupController(contentView: myView)
// Use popupController.statusItem to customize the NSStatusItem, set a title or an image
popupController.statusItem.button?.title = "Test"
popupController.statusItem.length = 70
// Use popupController.backgroundView to customize the popup's background
popupController.backgroundView.backgroundColor = NSColor.windowBackgroundColor // Default value
// Customize animations, view sizes
popupController.openDuration = 0.15 // Default value
popupController.closeDuration = 0.2 // Default value
popupController.arrowSize = CGSize(width: 12, height: 8) // Default value
popupController.contentInset = 1 // Default value
// Use callbacks to user actions (optional)
popupController.shouldOpenPopup = { keys in return true }
popupController.willOpenPopup = { keys in debugPrint("Will open popup!") }
popupController.didOpenPopup = { debugPrint("Opened popup!") }
popupController.willClosePopup = { debugPrint("Will close popup!") }
popupController.didClosePopup = { debugPrint("Closed popup!") }
// Resize your popup to your liking
popupController.resizePopup(width: 300, height: 400)