PhamBaTho / BTNavigationDropdownMenu

The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.
MIT License
2.69k stars 410 forks source link

How to use the drop down from the navigation bar's top right side #125

Open ayushmandey97 opened 7 years ago

ayushmandey97 commented 7 years ago
screen shot 2017-07-01 at 3 48 43 pm

So the bar button item having ". . ." is where I want the dropdown to happen, instead of the title. Any ideas as to how to accomplish this?

PhamBaTho commented 7 years ago

@ayushmandey97 currently the feature you're requesting is not supported. But I do want it because the rightButtonBarItem is also a part of navigation view. Thanks.

(just out of curious, why do you close this interesting feature request?)

ayushmandey97 commented 7 years ago

Actually I was able to find a way to do that, so I closed it. My bad.

So this is how I did it:

  1. Drag a UIView to the right side of the navigation bar. And create an outlet to it named "navOptionView".
screen shot 2017-07-06 at 2 18 56 pm
  1. Use this code snippet to make it work like I wanted it to.
//Setting the toolbar for dropdown menu
let menuView = BTNavigationDropdownMenu(title: ". . .",  items: items as [AnyObject])
self.navOptionView.customView = menuView
menuView.didSelectItemAtIndexHandler = {[weak self] (indexPath: Int) -> () in
      print("Did select item at index: \(indexPath)")
}
PhamBaTho commented 7 years ago

Nice workaround. Thanks for sharing 👍

ayushmandey97 commented 7 years ago

No problem. Just one more thing, incase someone implements this till the feature is ready. Inside the BTNavigationDropdownMenu.swift file, comment out the following line.

func setMenuTitle(_ title: String) {
        //self.menuTitle.text = title
}

This is so that the ". . ." button doesn't change every time you select an option.

djayhsu commented 7 years ago

@ayushmandey97 Another option is to just set menuView.shouldChangeTitleText = false

ivanJovanovik commented 4 years ago

Can I use Image ( three dots ) for right bar button and make dropdown ?