I was able to "present" a new view controller, over another, UNDER the tab bar, by setting modalPresentationStyle
to .currentContext
.
let newViewController = UIViewController()
newViewController.view.backgroundColor = UIColor.red
newViewController.modalPresentationStyle = .currentContext
newViewController.modalTransitionStyle = UIModalTransitionStyle.flipHorizontal
present(newViewController, animated: true, completion: nil)
Edit: From more testing, the above can have some buggy behavior if someone changes the tab WHILE the newViewController
is presented.
To "fix," I created a "switcher" - a UIViewController
that animates between the view controllers that I want to flip UNDER the tab bar:
view.addSubview(nextView)
UIView.transition(from: currentView,
to: nextView,
duration: 0.5,
options: animation,
completion: { (_) in
currentView.removeFromSuperview()
})
In this case, currentView
is the view of ViewControllerOne (the currently visible one), and the nextView
is view of ViewControllerTwo (the one we want to present).