@elemans I agree this is a great new feature, though my observations are a bit different
Setting the badge value with .count() or .string() works for me, but I did have some struggles with colors. I believe setting the .badge property to some non-nil value early on in the UIBarButtonItem lifecycle seemed to help.
For example, this code in a UIViewControllers viewDidLoad did produce a cyan on black badge with value 123:
self.buttonHistory = UIBarButtonItem.init(image: ...)
if #available(iOS 26.0, *) {
self.buttonHistory.badge = .count(123)
self.buttonHistory.badge?.backgroundColor = .black
self.buttonHistory.badge?.foregroundColor = .cyan
}
self.navigationItem.rightBarButtonItem = buttonHistory
and I found that as long as the .badge property is initialized early on to a non-nil value, like shown above (even initializing to .none), then I could subsequently change its value, background, and foreground colors.
In my case the UIBarButtonItem is in a UINavigationBar not a UIToolbar, not sure if this makes a difference.