skip to Main Content

I made an apps with only using XIB (without storyboard). so to navigate I’m using this code to push some of the views:

let vc = SecondViewController()
self.navigationController?.pushViewController(vc, animated: true)

I already make the first vc as rootvc, so it automatically created navigation bar for me.

the problem is the navigation bar generated not at top of the screen and leaving some white space gap. So here is the image when I’m using large title

enter image description here

and here is the normal one

enter image description here

I have tried to run it without safe area layout as well.
what happened is the navbar stayed there but the view goes up (through behind navbar).

4

Answers


  1. navigationController.isNavigationBarHidden = true
    

    Try adding this line to your code for hide default navigation bar.

    Login or Signup to reply.
  2. I’ve experienced this kind of problem, too.

    There are many ways to remove white space.

    I want to help you this way.

    Add UIView above navigation Bar.
    enter image description here

    and then, Fix UIView Top constraint.
    enter image description here

    and change UIView Color.
    enter image description here

    this is result.

    enter image description here

    Again, there are many ways…

    Login or Signup to reply.
  3. Use this in your view controller’s class:

    navigationController?.setNavigationBarHidden(true, animated: animated)
    
    Login or Signup to reply.
  4. enter image description here

    you can change your status bar colour by using. i don’t remember the code but from here you can also can also change your colour in two Default styles

    //and use this to hide and show your navigation  bar 
    navigationController.isNavigationBarHidden = true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search