I have a UIView
that has a layout constraint to the bottom of the safe area. This is inside a UIViewController
inside a UINavigationController
. It works fine when the navigation bar is in-between the large title and the "regular" title. However when bouncing lower the UINavigationBar
covers the custom view.
How can I lock the position of a custom view to the bottom of a bouncing NavigationBar. Storyboard solution would be optimal, Swift solution would be sufficient.
You need to add menuView
in navigationBar
let menuView = UIView()
menuView.backgroundColor = .red
menuView.translatesAutoresizingMaskIntoConstraints = false
self.navigationController?.navigationBar.addSubview(menuView)
[menuView.leadingAnchor.constraint(equalTo: (self.navigationController?.navigationBar.leadingAnchor)!),
menuView.topAnchor.constraint(equalTo: (self.navigationController?.navigationBar.bottomAnchor)!),
menuView.trailingAnchor.constraint(equalTo: (self.navigationController?.navigationBar.trailingAnchor)!),
menuView.heightAnchor.constraint(equalToConstant: 60)].forEach{ $0.isActive = true }
Result
But you have to maintain contentInset of UITableView/UICollectionView/UIScrollView & Scroll indicator
Suggestions
Use Section Header of TableView/CollectinView in this type of situation.