My view is going under the navigation bar. Most of the view is showing, except the top part which is covered up by the Nav bar. How do I prevent that?
You must set the anchor to safeAreaLayoutGuide like this:
NSLayoutConstraint.activate([
myView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)
])
same thing for bottom if you have a tabbar:
NSLayoutConstraint.activate([
myView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
])
Also, remember to set .translatesAutoresizingMaskIntoConstraints = false
on "myView"
self.navigationController.navigationBar.isTranslucent = false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.