Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - overlay view in outer view controller #26

Open
gerchicov-bp opened this issue Dec 14, 2018 · 2 comments
Open

Feature request - overlay view in outer view controller #26

gerchicov-bp opened this issue Dec 14, 2018 · 2 comments

Comments

@gerchicov-bp
Copy link

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

@qmathe
Copy link
Owner

qmathe commented Dec 15, 2018

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.

@qmathe
Copy link
Owner

qmathe commented May 12, 2019

I took a look at various approaches to solve your problem. I thought about two solutions:

  • change DropDownMenu.container to 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(_:))
    ))

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants