DropdownMenu 1.0.0

DropdownMenu 1.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2014
SPMSupports SPM

Maintained by Suric Zhang.




  • By
  • Nils Mattisson

Teambition

DropdownMenu is a dropdown menu for navigationController in Swift, It can be associated in any place if have a navigationController

Features

  • Only text cell
  • Image and text cell
  • Highlight cell
  • Seleted cell
  • Detail accessory cell

Requirements

  • iOS 8.0
  • Xcode 7.3+

Communication

Installation

**Embedded frameworks require a minimum deployment target of iOS 8

Usage

Import framework to your class

import DropdownMenu

Add code for your action

Without Section

func showMenu(sender: UIBarButtonItem) {
        let item1 = DropdownItem(title: "NO Image")
        let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File")
        let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .Highlight)
        let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .Highlight, accessoryImage: UIImage(named: "accessory")!)

        let items = [item1, item2, item3, item4]
        let menuView = DropdownMenu(navigationController: navigationController!, items: items, selectedRow: selectedRow)
        menuView.delegate = self
        menuView.showMenu()
    }

With Section

 @IBAction func showMenu(_ sender: UIBarButtonItem) {
        let item1 = DropdownItem(title: "NO Image")
        let item2 = DropdownItem(image: UIImage(named: "file")!, title: "File")
        let item3 = DropdownItem(image: UIImage(named: "post")!, title: "Post", style: .highlight)
        let item4 = DropdownItem(image: UIImage(named: "post")!, title: "Event", style: .highlight, accessoryImage: UIImage(named: "accessory")!)

        let section0 = DropdownSection(sectionIdentifier: "Teambition", items: [item1, item2])
        let section1 = DropdownSection(sectionIdentifier: "Space", items: [item3, item4])

        let menuView = DropdownMenu(navigationController: navigationController!, sections: [section0, section1], selectedIndexPath: selectedIndexPath)
        menuView?.delegate = self
        menuView?.showMenu()
    }

Handle delegate

extension ViewController: DropdownMenuDelegate {
    func dropdownMenu(dropdownMenu: DropdownMenu, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        print("DropdownMenu didselect \(indexPath.row)")
    }
}

for detail, Please check the demo

License

DropdownMenu is released under the MIT license.