A simple dropdown menu component for iPhone

Overview

AZDropdownMenu

Build Status Version License Platform Language

AZDropdownMenu is a simple dropdown menu component that supports Swift.

Screenshots

Code used in the screencast are included in the bundled sample project.

screencast

Demo Project

To run the demo project, clone the repo with git clone https://github.com/Azuritul/AZDropdownMenu.git, and run pod install from the Example directory first.

Requirements

  • iOS 8 or above
  • Xcode 8 or above
  • Swift 3

Installation

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

use_frameworks!
pod 'AZDropdownMenu'

Use version 1.1.2 if you don't need Swift 4 support.

Usage

Declare an array of texts that are served as the item in the menu.

let titles = ["Action 1", "Action 2", "Action 3"]

Then pass the array to the initializer

let menu = AZDropdownMenu(titles: titles)

Set up so that the UIBarButtonItem is asso

ated with a function that shows the menu

let button = UIBarButtonItem(image: UIImage(named: "menu_image"), style: .Plain, target: self, action: "showDropdown")
navigationItem.leftBarButtonItem = menuButton

Calling public func showMenuFromView(view:UIView) can then show the menu.

func showDropdown() {
    if (self.menu?.isDescendantOfView(self.view) == true) {
        self.menu?.hideMenu()
    } else {
        self.menu?.showMenuFromView(self.view)
    }
}

The handler public var cellTapHandler : ((indexPath:NSIndexPath) -> Void)? would be called when menu item is tapped. So place code in here to do whatever you want. For example

menu.cellTapHandler = { [weak self] (indexPath: NSIndexPath) -> Void in
    self?.navigationController?.pushViewController(controller, animated:true)
}

Create menu with icons

Pass in a AZDropdownMenuItemData in the initializer: public init(dataSource:[AZDropdownMenuItemData]) and you are good to go.

Take a look at the sample project in this repository to get more usage of the library.

Configurable options

Currently AZDropdownMenu can be customized with the following properties. More will come in the future.

  • itemHeight Row height of the menu item. Default is 44.
  • itemColor The background color of the menu item. Default is white.
  • itemFontColor The text color of the menu item. Default is black.
  • itemFontSize Font size of the menu item. Default is 14.0
  • itemFont Font used in the menu. Default is 'Helvetica'
  • itemAlignment The alignment of the menu item. Default is left-aligned.
  • itemSelectionColor The background color of the menu item while it is tapped. Default is gray.
  • overlayAlpha The transparency for the background overlay. Default is 0.5
  • overlayColor Color for the background overlay. Default is black.
  • menuSeparatorStyle The separator of the menu. Default is single line.
  • menuSeparatorColor The color of the separator. Default is light gray.
  • itemImagePosition The position of image in the menu. Can be positioned before or after the text. Default is .Prefix.
  • shouldDismissMenuOnDrag If set to true, menu would be dismissed on drag. Default value is false.

Version

  • 1.1.3

    • Update for Swift 4 syntax
  • 1.1.2

    • Update for Swift 3 syntax
  • 1.1.1

    • Update for Swift 2.2's #selector syntax
  • 1.1.0

    • Added shouldDismissMenuOnDrag option, menu would be dismissed on drag if this option is enabled
    • Modified the sample project with an example using UITableView.
    • Added gesture handler for the menu.
    • Extract config struct to a separate file
    • Update readme.
  • 1.0.0

    • Added itemImagePosition option, now can configure the icon position.
    • Changed icon sets and its corresponding location in the sample project.
    • Modified sample project's appearance a little bit.
    • Modified sample project's structure.
    • Added CHANGELOG.md
  • 0.6.1

    • Update readme
  • 0.6.0

    • Now can use icons in the menu.
    • Added configuration options: menuSeparatorColor, itemFont
  • 0.5.3

    • Now can configure item's background color while tapped

Credit

Author

Chris Wu (Azuritul), [email protected]

License

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

Comments
  • Any chance to upgrade to Swift 3 soon?

    Any chance to upgrade to Swift 3 soon?

    Hi. I love your library. You know we're all in XCode 8 updating nightmare. I wonder if you are planning to release a new swift 3 compatible version soon.

    Thanks

    opened by rmvz3 2
  • Can't see the first and second cell

    Can't see the first and second cell

    Hi Guys

    I have this issue where I'm not able to see 1st and 2nd cell after I open the dropdown menu.

    I used two heights first menu?.itemHeight = 40 screen shot 2016-04-18 at 23 56 25

    and here i have menu?.itemHeight = 120 screen shot 2016-04-19 at 00 00 44

    I'm not sure why but is not working. The nav bar is 44 in height

    Can you help me with this ?

    Thanks in Advance !

    opened by YHSX88 2
  • Menu was covered by NavigationBar

    Menu was covered by NavigationBar

    simulator screen shot 2016 3 3 3 50 01

    Hi, I'm new to swift and thanks for developing such a nice control. I'm trying to use menu but I don't know why menu was covered by my navigation bar as pics above. and how to prevent the button twice or more clicked that makes the menu shows too much time on the default view.

    Thanks in advance :)

    opened by han76816 1
  • Configurable icon position

    Configurable icon position

    Bumped the version to 1.0.0!!

    Feature

    • [x] Added config option: itemImagePosition. Default is .Prefix

    Fix

    • [x] Fix build warning in xcode

    Enhancements

    • [x] The structure of sample program is updated.
    • [x] Icons used in the sample program are moved to xcassets.
    • [x] Names used in code's license block are made consistent( use my full name instead of nickname).

    Others

    • [x] Updated screenshot.
    • [x] Added CHANGELOG.md
    • [x] Replaced icon set with a new one. Previous Glyphicons are removed.
    opened by Azuritul 1
  • Add @objc attributes for Swift 4 compatibility

    Add @objc attributes for Swift 4 compatibility

    Description

    Swift 4 requires the @objc attribute on any function referenced by #selector. This pull request adds that attribute to two functions.

    Fix

    • Swift 4 compatibility
    opened by swoolcock 0
  • Update AZDropdownMenu.swift

    Update AZDropdownMenu.swift

    Added open func showMenuFromView(_ view:UIView, widthIndent indent: CGFloat) {

    Description

    Feature

    • [x]

    Fix

    • [x]

    Enhancement

    • [x]

    Others

    • [x]

    Related Issues

    opened by Nea88 0
  • Updated for Xcode 8 beta 6

    Updated for Xcode 8 beta 6

    Description

    Updated repo for use with Swift 3 and the last version of Xcode. This should probably be on its own branch.

    Others

    • Updated example project to use Cocoapods 1.0.
    opened by sammygutierrez 0
  • Handle Landscape ?

    Handle Landscape ?

    Hi

    Can someone please tell me how to set the menu so when user rotate the screen to landscape, the menu to be still showing on the whole screen width ?

    Thanks in Advance

    opened by YHSX88 0
  • Dismiss menu on dragging

    Dismiss menu on dragging

    Feature

    • [x] Now can choose to dismiss menu on dragging by setting shouldDismissMenuOnDrag to true

    Fix

    • [x] Now user should not be able to drag the whole menu #10

    Enhancement

    • [x] Update example project using UITableView
    opened by Azuritul 0
  • Configurable icon position

    Configurable icon position

    Bumped the version to 1.0.0!!

    Feature

    • [x] Added config option: itemImagePosition. Default is .Prefix

    Fix

    • [x] Fix build warning in xcode

    Enhancements

    • [x] The structure of sample program is updated.
    • [x] Icons used in the sample program are moved to xcassets.
    • [x] Names used in code's license block are made consistent( use my full name instead of nickname).

    Others

    • [x] Updated screenshot.
    • [x] Added CHANGELOG.md
    • [x] Replaced icon set with a new one. Previous Glyphicons are removed.
    opened by Azuritul 0
  • Added support for setting icons in menu

    Added support for setting icons in menu

    Feature

    • [x] Added configuration option: menuSeparatorColor, itemFont
    • [x] Now can set icons for menu.

    Others

    • [x] Added icons for sample project.
    • [x] Replaced CWDropdownMenu... with correct prefix AZDropdown...
    • [x] Updated readme
    opened by Azuritul 0
  • Icon tint config

    Icon tint config

    Hello Could you please add a feature to tint icon with any color? Using standard feature of UIImageView instead of extensions like this https://gist.github.com/lynfogeek/4b6ce0117fb0acdabe229f6d8759a139

    Thank you

    opened by gang018 0
  • CellTapHandler Assign-Error

    CellTapHandler Assign-Error

    Hi,

    even with your example I get following error message for this line: menu.cellTapHandler = { [weak self] (indexPath: NSIndexPath) -> Void in

    Message: Cannot assign value of type '(NSIndexPath) -> Void' to type '((IndexPath) -> Void)?'

    opened by danielbeicht 1
  • Issues on iPad with iOS 11

    Issues on iPad with iOS 11

    The menu is having some issues with iOS 11 on an iPad when used in a UISplitViewController context. See the attached screenshots. One shows a menu dropped on on the detail view controller (the right side). The text is somehow in the middle and the separator lines are only drawn half way, it looks a bit silly.

    In the other screenshot the menu is used in the master view controller (left side). It has only one item and it's cut off, the text should be "Toggle display mode".

    screen shot 2017-09-25 at 22 12 03 screen shot 2017-09-25 at 22 11 30

    opened by jan-ekholm 1
  • icon that is not scaled to fill

    icon that is not scaled to fill

    My icons aren't scaled to fill : capture d ecran 2017-06-07 a 17 30 40 I guess the tableview that is used in the dropdown menu is not set up, but I have no idea why it's not working on my code…

    opened by petaire92 0
✨ Awesome Dropdown menu for iOS with Swift 5.0

The eligible dropdown menu for iOS, written in Swift 5, appears dropdown menu to display a view of related items when a user click on the dropdown menu. You can customize dropdown view whatever you like (e.g. UITableView, UICollectionView... etc)

Kyle Yi 1.3k Dec 26, 2022
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.

Introduction The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when

Tho Pham 2.7k Dec 28, 2022
🔻 Dropdown Menu for iOS with many customizable parameters to suit any needs

MKDropdownMenu Dropdown Menu for iOS with many customizable parameters to suit any needs. Inspired by UIPickerView. Installation CocoaPods MKDropdownM

Max Konovalov 531 Dec 26, 2022
JNDropDownMenu - Easy to use TableView style dropdown menu.

Overview Swift version of https://github.com/dopcn/DOPDropDownMenu Easy to use TableView style dropdown menu. Setup The only thing you

Javal Nanda 65 Jun 27, 2021
Fantastic dropdown in Swift

Dropdowns ❤️ Support my app ❤️ Push Hero - pure Swift native macOS application to test push notifications Quick Access - Organise files in the Mac men

Khoa 307 Oct 17, 2022
An elegant dropdown for iOS written in Swift.

UIDropDown An elegant dropdown for iOS written in Swift. Overview UIDropDown allows you to pick an option in a table just like dropdowns in web. It co

Isaac Gongora 87 Mar 30, 2022
Slide-Menu - A Simple Slide Menu With Swift

Slide Menu!! Весь интерфейс создан через код

Kirill 0 Jan 8, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
EasyMenu - SwiftUI Menu but not only button (similar to the native Menu)

EasyMenu SwiftUI Menu but not only button (similar to the native Menu) You can c

null 10 Oct 7, 2022
Swift-sidebar-menu-example - Create amazing sidebar menu with animation using swift

 SWIFT SIDEBAR MENU EXAMPLE In this project I create a awesome side bar menu fo

Paolo Prodossimo Lopes 4 Jul 25, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion

CIRCLE MENU Simple, elegant UI menu with a circular layout and material design animations We specialize in the designing and coding of custom UI for M

Ramotion 3.4k Dec 29, 2022
A simple side menu for iOS written in Swift.

ENSwiftSideMenu A lightweight flyover side menu component for iOS with the UIDynamic's bouncing animation, UIGestures and UIBlurEffect. Allows you to

Evgeny Nazarov 1.8k Dec 21, 2022
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.

▤ SideMenu If you like SideMenu, give it a ★ at the top right of this page. SideMenu needs your help! If you're a skilled iOS developer and want to he

Jon Kent 5.4k Dec 29, 2022
a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

lyricsify a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

Krisna Pranav 4 Sep 16, 2021
A simple circle style menu.

Support CocoaPods. New at 2019.02.25 Use @property (nonatomic, assign) BOOL isOpened; can open or close RoundMenu. use -(void)setButtonEnable:(BOOL)en

zsy78191 383 Dec 21, 2022
UIKit drop down menu, simple yet flexible and written in Swift

DropDownMenuKit DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding an

Quentin Mathé 258 Dec 27, 2022
Simple and Elegant Drop down menu for iOS 🔥💥

SwiftyMenu is simple yet powerfull drop down menu component for iOS. It allow you to have drop down menu that doesn't appear over your views, which gi

Karim Ebrahem 502 Nov 29, 2022