UINavigationBar slides away instead of staying on place
I created demo project to show the problem. We have two view controllers inside UINavigationController. MainViewController which is the root. class MainViewController: UIViewController { lazy var button: UIButton = { let button = UIButton() button.setTitle("Detail", for: .normal) return button }() override func viewDidLoad() { super.viewDidLoad() navigationItem.title = "Main" view.backgroundColor = .blue view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true button.centerYAnchor.constraint