How to make a single UIBarButtonItem to several UINavigationController's?

Hi all.

Is the project structure:
TabController -> NavigationController -> ViewController
-> NavigationController -> ViewController
-> NavigationController -> ViewController

I need to have in navigeyshen controller UIBarButtonItem, by pressing on which view controller shows a small view.

It turns out that there are three tab, each tab in navigeyshen controller has a button, clicking on which the view appears.

The question is how to implement it? The option to do three views, three buttons and three handler for them in each view controller I think it is not the best. How do you solve such tasks?
June 8th 19 at 17:19
2 answers
June 8th 19 at 17:21
To make the base class heir to a NavigationController and it once to register the button and the action on it. Then, all the other navigationController inheriting from the base. Somehow so.
June 8th 19 at 17:23
I propose to create a single method in which you will be able to set barButtonItem, and then call it from other classes.

func settingUpBarButtonItem(navBar:UINavigationController) {
 let barButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(self.barButtonAction))
 navBar.navigationItem.rightBarButtonItem = barButton

 @objc func barButtonAction() {
 //Do something

Find more questions by tags iOSMobile developmentDesigning softwareSwift