I want a view to slide up, outside the visible area, when the navigation bar hides.
The view is attached to the safeAreaLayoutGuide:
topConstraint = myView.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor)
To slide it out, the constraint is changed:
topConstraint.constant = hidden ? -(myView.frame.height) : 0
This works for iPhone 7 but not for iPhone X. When the navigation is hidden, there is a gap between the view.topAnchor
and the view.safeAreaLayoutGuide.topAnchor
.
The easiest way would be to attach the view to the bottom anchor of the navigation bar, but the app crashes when trying this:
topConstraint = myView.topAnchor.constraint(equalTo: navigationController!.navigationBar.bottomAnchor)
So how can I slide myView
out of the visible area?