Show overflow menu (more menu) as disabled in iOS 16+

Hi! I'm moving my UINavigationBar and UINavigationItem to the iOS 16 style and having trouble with disabling buttons.

Before:

I'm defining rightBarButtonItems with a few barButtonItems plus a (custom) menuButtonItem (which has a menu with some more actions).

After:

I'm defining trailingItemGroups and let the system create an overflow menu dynamically, depending on space. I'm also defining some additionalOverflowItems.

Here's the problem:

How can I access the button/barButtonItem that is showing the overflow menu and call isEnabled = false? My UI, so far, has disabled all buttons during edit mode. I don't want to hide them, but have them grayed out, including the overflow menu button.

class MyVC : UIViewController {
    // ...
    override func setEditing(_ editing: Bool, animated: Bool) {
        super.setEditing(editing, animated: animated)

        // ...

        // This doesn't disable the overflow menu button
        navigationItem
            .trailingItemGroups
            .forEach {
                $0.barButtonItems
                    .forEach {
                        $0.isEnabled = !isEditing
                    }
            }
    }
}

The design for the overflow button is not that you disable it, but that it disappear when there is nothing in it. There is no way to access the button that corresponds to it to modify its behavior.

Show overflow menu (more menu) as disabled in iOS 16+
 
 
Q