Я связал оба navigationController
и tabBarController
вот так
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = mainStoryboard.instantiateViewController(withIdentifier: "TabAction") as UIViewController
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = UINavigationController(rootViewController: TabBarController())
self.window?.makeKeyAndVisible()
let navigationController = UINavigationController.init(rootViewController: viewController)
UIApplication.shared.keyWindow?.rootViewController = viewController
self.window?.rootViewController = navigationController
self.window?.makeKeyAndVisible()
код для элемента кнопки в контроллере вида:
super.viewDidLoad()
// registering table
recruitmentDbView?.register(UINib(nibName: "recruitmentDashboardCell", bundle: nil), forCellReuseIdentifier: "CustomCell")
// setting colour to navigation bar
self.navigationController?.navigationBar.barTintColor = UIColor(red: 18/255, green: 41/255, blue: 50/255, alpha: 1)
// setting barbutton items on navigation bar
let rightFilterBarButtonItem: UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "FilterIcon"), style: .plain, target: self, action: nil)
rightFilterBarButtonItem.tintColor = UIColor.white
let rightSearchBarButtonItem: UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "SearchIcon"), style: .plain, target: self, action: nil)
rightSearchBarButtonItem.tintColor = UIColor.white
self.navigationItem.rightBarButtonItems = [rightFilterBarButtonItem,rightSearchBarButtonItem]
self.navigationItem.leftBarButtonItem?.isEnabled = true
self.navigationItem.backBarButtonItem?.isEnabled = false
let leftBackBarButtonItem: UIBarButtonItem = UIBarButtonItem(image: UIImage(named: "BackIcon"), style: .plain, target: self, action: nil)
self.navigationItem.leftBarButtonItem = leftBackBarButtonItem
self.navigationItem.title = "Recruit - Dashboard"
let textAttributes = [NSAttributedString .Key.foregroundColor:UIColor.white]
self.navigationController?.navigationBar.titleTextAttributes = textAttributes
}