In the days of QuickTime Player and its paid counterpart, QuickTime Pro, Apple used a menu badge to indicate when a feature was only available in the Pro version of the app.
This has been difficult to replicate using the public macOS SDK… until now. macOS 14 “Sonoma” introduces NSMenuItemBadge, which makes implementing this trivial in a modern Mac app.
Given a NSMenuItem, you can simply assign it the badge
property:
// AppKit
@objc extension NSMenuItem {
func applyProBadge() {
if #available(macOS 14.0, *) {
if requiresUnlock() {
badge = NSMenuItemBadge(string: "Pro")
} else {
badge = nil
}
}
}
}
In SwiftUI, you can achieve this by using the badge
modifier:
// SwiftUI
Menu {
Button("Pro Feature") {
// ...
}
.badge(requiresUnlock() ? "Pro" : nil)
}
The result looks like this:
We’ve been moving some of our Mac apps to a freemium model where basic features are available for free, and more advanced features require a one-time purchase. This is a great way of indicating to users which features are available for free, and which are only available in the Pro version, and it’s a nice throwback to the good old days of Mac OS X.