Latest 0.1.6
Homepage https://github.com/arminlikic/SwiftElegantDropdownMenu
License MIT
Platforms ios 8.0, requires ARC
Authors

Build Status
Version
License
Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Description

This component provides an easy, configurable dropdown menu with the ability to place it anywhere. It comes with a simple item selected callback and a variety of configurable options. This component is inspired by the BTNavigationDropdownMenu from PhamBaTho.

alt tag

Installation

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

use_frameworks!
pod "SwiftElegantDropdownMenu"

Usage:

import SwiftElegantDropdownMenu

Example 1

Start by creating an array of dropdown elements:

let items = ["Zeus", "Hades", "Poseidon", "Chronos", "Aphrodite", "Artemis", "Hefestus"]

Create a new instance of SwiftElegantDropdownMenu:

let dropdownMenu = SwiftElegantDropdownMenu(title: items.first!, items: items)

Add the menu to your view as any other UIVIew:

self.view.addSubview(dropdownMenu)

Example 2

Create a new UIView storyboard element, assign the SwiftElegantDropdownMenu class to it, and create an outlet in your viewcontroller:

@IBOutlet weak var dropdownMenu: SwiftElegantDropdownMenu!

Assign the items and title properties to it:

self.dropdownMenu.items = items
self.dropdownMenu.title = items.first!

Example 3

You can handle the selection using a completion handler:

self.dropdownMenu.onItemSelect = {

(index, item) -> () in

// do something

}

You can handle what happens when the menu button is tapped:

self.dropdownMenu.onMenuButtonTapped = {

willOpen -> () in

// do something

}

Also, you have the freedom to customize the layout of the dropdown to match your needs:

...
self.dropdownMenu.configuration.titleFont = UIFont(name: "Arial", size: 22)!
self.dropdownMenu.configuration.cellTextColor = UIColor.redColor()
self.dropdownMenu.configuration.cellFont = UIFont(name: "Courier New", size: 18)!
...

Changelog

0.1.6 (11-28-2015)

  • Fixed vertical position issue for list.

0.1.5 (11-28-2015)

  • Fixed a crash issue.
  • Added an onMenuButtonTapped handler.

0.1.4 (11-28-2015)

  • Improved the dropdown to handle the case when there are multiple dropdowns present.
  • Added the ability to close the dropdown by tapping on the outter area.

0.1.3 (11-27-2015)

  • The issue that was causing the app to crash when multiple dropdowns have been added on the view has been resolved.

Author

Armin Likic, [email protected]

License

SwiftElegantDropdownMenu is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftElegantDropdownMenu",
    "version": "0.1.6",
    "summary": "An elegant dropdown menu for Swift, that's easy to use.",
    "description": "This component provides an easy, configurable dropdown menu with the ability to place it anywhere. It comes with a simple item selected callback and a variety of configurable options. This component is inspired by the **BTNavigationDropdownMenu** from **PhamBaTho**.",
    "homepage": "https://github.com/arminlikic/SwiftElegantDropdownMenu",
    "license": "MIT",
    "authors": {
        "Armin Likic": "[email protected]"
    },
    "source": {
        "git": "https://github.com/arminlikic/SwiftElegantDropdownMenu.git",
        "tag": "0.1.6"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "screenshots": [
        "https://raw.githubusercontent.com/arminlikic/SwiftElegantDropdownMenu/master/Assets/demo.gif"
    ],
    "resource_bundles": {
        "SwiftElegantDropdownMenu": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This