Latest 5.0.0
License MIT
Platforms ios 8.0

alt tag

License: MIT


What is new

  • support Swift 5.0
  • fix the problem that when title is too long will not display normally


This elegant Swift dropdown menu appears underneath the navigation bar to display a list of related items when a user clicks on the navigation title.

alt tag


NavigationDropdownMenu is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NavigationDropdownMenu', '~> 5.0.0'

Go ahead and import NavigationDropdownMenu into your own Swift files

import NavigationDropdownMenu

Note: This library supports for Xcode 10.2 Swift 5 and embedded frameworks.



Start by creating an Array that contains strings as elements of a dropdown list:

let items = ["Most Popular", "Latest", "Trending", "Nearest", "Top Picks"]

Create a new instance of NavigationDropdownMenu:

let menuView = NavigationDropdownMenu(navigationController: self.navigationController, containerView: self.navigationController!.view, title: Title.title("Dropdown Menu"), items: items)

or like this:

let menuView = NavigationDropdownMenu(title: Title.index(1), items: items)

Title is an enum. We can set Title.title(string) or Title.index(Int) (Note: Title.index is the index of defined items array).

By default, navigationController is the topmost navigation controller and containerView is keyWindow.

(keyWindow is recommended for containerView so that the black overlay can cover the whole screen. In some cases, keyWindow doesn’t work properly, like using with side menu, (e.g. SWRevealViewController), the dropdown menu doesn’t move along with the parent view or navigation controller. To workaround this issue, you can use self.navigationController!.view.)

Set title of navigation bar as menuView:

self.navigationItem.titleView = menuView

Call NavigationDropdownMenu closure to get the index of selected cell:

menuView.didSelectItemAtIndexHandler = {[weak self] (indexPath: Int) -> () in
            print("Did select item at index: (indexPath)")
            self.selectedCellLabel.text = items[indexPath]
} or menuView.hide() to show or hide dropdown menu manually.

menuView.toggle() to toogle dropdown menu shown/hide.

menuView.isShown (Boolean type) property to check showing state of dropdown menu.

menuView.updateItems(items: [AnyObject]) to update items in dropdown menu.


First, assign the items and frame for the dropdown menu. Then, customize the look and feel of the menu by overriding these properties:

cellHeight – Cell height Default is 50

cellBackgroundColor – Cell background color Default is whiteColor()

cellSeparatorColor – Cell separator color Default is darkGrayColor()

cellTextLabelColor – Text color inside of the cell Default is darkGrayColor()

cellTextLabelFont – Font inside the cell Default is HelveticaNeue-Bold, size 17

navigationBarTitleFont – Navigation bar title font Default is HelveticaNeue-Bold, size 17

cellTextLabelAlignment – Text alignment inside of the cell Default is .Left

cellSelectionColor – Selected color of the cell Default is lightGrayColor()

checkMarkImage – Checkmark icon for the cell.

animationDuration – Animation duration for showing/hiding of the menu Default is 0.5s

arrowImage – Arrow next to the navigation title

arrowPadding – Padding between the navigation title and arrow. Default is 15

maskBackgroundColor – Mask layer color Default is blackColor()

maskBackgroundOpacity – Opacity of the mask layer Default is 0.3

menuTitleColor – Title color displayed in the menu. Default is lightGrayColor()

shouldKeepSelectedCellColor – Selected cell color visibility when menu is shown Default is false

shouldChangeTitleText – Ability to change the selected title text Default is true

selectedCellTextLabelColor – Selected cell text label color Default is darkGrayColor()

arrowTintColor – Tint color of the arrow. Default is whiteColor()


  • iOS 8.0+ (CocoaPods with Swift support will only work on iOS 8.0+. Alternatively, you will have to import library manually to your project)
  • Xcode 9.0+, Swift 4.0


See the CHANGELOG for details


BTNavigationDropdownMenu is available under the MIT License. See the LICENSE for details.

Latest podspec

    "name": "NavigationDropdownMenu",
    "version": "5.0.0",
    "summary": "The elegent navigation dropdown menu",
    "description": "The elegant **dropdown menu**, written in **Swift**, appears underneath **navigation bar** to display a list of related items when a user click on the navigation title.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Xiaoye__220": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "5.0.0"
    "source_files": "Source/**/*.swift",
    "resources": "Source/*.bundle",
    "swift_versions": "5.0"

Pin It on Pinterest

Share This