You can always create a UINavigationController
instance and add your view controller (the one you want to present modally) to it. Then, modally present the new UINavigationController
instance instead of your view controller. This will show your view controller (because it is contained in the UINavigationController
) with a navigation bar (because it is in a UINavigationController
).
Here is an example:
let rootViewController = UITabBarController() // Lets assume this is your root view controller
let modalViewController = UIViewController() // Lets assume this is the view controller you want to present modally
// Here we wrap the modal controller in a navigation controller and then present it modally
let navigationController = UINavigationController(rootViewController: modalViewController)
rootViewController.present(navigationController, animated: true, completion: nil)