DropDownMenuKit
DropDownMenuKit copied to clipboard
Feature request - overlay view in outer view controller
In my case UITabBarController is root. So if I add this control into inner navigation bar then it won't overlay UITabBar and UITabBarController is still clickable
Hi,
ok, I understand the problem. I'll take a look at what I can do and come back to you. If you have any solution to solve this, let me know.
I took a look at various approaches to solve your problem. I thought about two solutions:
- change
DropDownMenu.containerto point the tab bar view itself (or some other superview) - present an extra background view covering the tab bar when the menu is shown
The first option is the easiest but doesn't always play well with a transparent navigation bar, since the background view cannot be drawn under the navigation bar anymore. The second option is probably the best choice in your case, unless the menu is too long and needs to be scrollable (with this option it wouldn't extend all the way to the bottom).
To support the second option, I introduced a new API to support custom hide/show transitions for DropDownMenu. You can use this API to:
- override menu and background animations
- run extra animations (as I'm suggesting for your issue)
The changes have been committed in master (using Swift 5). Now you can write something like this to have the tab bar appearing under the menu overlay:
let footer = UIView()
func viewDidLoad() {
super.viewDidLoad()
let tabView = tabBarController.view
footer.translatesAutoresizingMaskIntoConstraints = false
footer.isHidden = false
footer.backgroundColor = .black
footer.alpha = 0
tabView.addSubview(footer)
NSLayoutConstraint.activate([
footer.widthAnchor.constraint(equalTo: tabView.widthAnchor),
footer.topAnchor.constraint(equalTo: tabBarController.tabBar.topAnchor),
footer.bottomAnchor.constraint(equalTo: tabView.bottomAnchor),
footer.leftAnchor.constraint(equalTo: tabView.leftAnchor)
])
navigationBarMenu.transition.show.append(.init(
before: { self.footer.isHidden = false },
change: { self.footer.alpha = 0.7 }
))
navigationBarMenu.transition.hide.append(.init(
change: { self.footer.alpha = 0 },
after: { self.footer.isHidden = true }
))
footer.addGestureRecognizer(UITapGestureRecognizer(
target: navigationBarMenu,
action: #selector(DropDownMenu.tap(_:))
))
}