skip to Main Content

I have a UIViewController that contains a UITabBar. I want to push a new UIViewController that covers the current context (so during the animation it shows the new UIViewController covering the UITabBar). How can I do this?

I have tried using the following to push the view but this is not pushed over the UITabBar.

let vc = ViewController2()
vc.modalPresentationStyle = .overFullScreen
navigationController?.pushViewController(vc, animated: true)

I also thought that maybe I could just hide the UITabBar on ViewController2’s viewWillAppear and show it on its viewWilDisappear; however, this just makes the UITabBar appear halfway through the dismissal (it looks really bad if you slowly slide to dismiss the view).

2

Answers


  1. You must use presentViewController, not push.

    Login or Signup to reply.
  2. In storyboard, go to the UIViewController you are going to push.
    Go to attributes inspector and check "Hide Bottom Bar on Push"

    This can also be done programmatically:

    let vc = viewController1()
    vc.hidesBottomBarWhenPushed = true
    navigationController?.pushViewController(vc, animated: true)
    

    Hope it helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search