UIKit drop down menu, simple yet flexible and written in Swift

Overview

DropDownMenuKit

Build Status Platforms iOS Language Swift 5 License MIT

DropDownMenuKit is a custom UIKit control to show a menu attached to the navigation bar or toolbar. The menu appears with a sliding animation and can be deeply customized. For example, with icons, embedded controls, or a checkmark to denote a selected row among multiple menu cells.

The control is made up of three parts:

  • DropDownMenu: the menu itself, a UIView subclass that contains a UITableView presenting one or more DropDownMenuCell(s)
  • DropDownMenuCell: a menu entry, implemented as a UITableViewCell subclass
  • DropDownMenuTitleView: an optional title view to toggle the menu, which is usually put in the navigation bar and acts as a disclosure indicator

Screenshot

Screenshot

To see in action, take a look at the very beginning of Placeboard demo video.

Compatibility

DropDownMenuKit requires at least Xcode 9 and supports iOS 8 and higher.

Swift DropDownMenuKit
5 0.9 or branch swift-5
4.2 0.8.6 or branch swift-4.2
4.X 0.8.5 or branch swift-4.1
3.X 0.8.4 or branch swift-3.2

Installation

Carthage

Add the following line to your Cartfile, run carthage update to build the framework and drag the built DropDownMenuKit.framework into your Xcode project.

github "qmathe/DropDownMenuKit"

CocoaPods

Add the following lines to your Podfile and run pod install with CocoaPods 0.36 or newer.

use_frameworks!

pod "DropDownMenuKit"

Manually

If you don't use Carthage or CocoaPods, it's possible to drag the built framework or embed the source files into your project.

Framework

Build DropDownMenuKit framework and drop it into your Xcode project.

Files

Drop DropDownMenu.swift, DropDownMenuCell.swift, DropDownTitleView.swift and DropDownMenuKit.xcassets into your Xcode project.

App Extension Usage

Build Settings

Add -DAPP_EXTENSION to DropDownMenuKit > Build Settings > Other Swift Flags.

Restrictions

  • DropDownMenuCell.menuAction must take a single argument
  • DropDownMenuCell.menuTarget must not be nil
Comments
  • The Dropdownmenu won't scroll when too many items

    The Dropdownmenu won't scroll when too many items

    I'm using this array with 19 items on it, some items are then listed outside of the iphone screen and the menu don't scroll so users can't reach the 19th elements of my array ...

    ["Alimentaire","Artisanat","Bien-être","Décoration","E-commerce","Distribution","Hôtellerie","Immobilier","Informatique","Métallurgie","Médical","Nautisme","Paramédical","Restauration","Sécurité","Textile","Tourisme","Transport","Urbanisme"]

    The code I used to dynamically load array into your menu from your demo project

    `func prepareNavigationBarMenu(_ currentChoice: String) { navigationBarMenu = DropDownMenu(frame: view.bounds) navigationBarMenu.delegate = self

    	let toutesCat = ["Alimentaire","Artisanat","Bien-être","Décoration","E-commerce","Distribution","Hôtellerie","Immobilier","Informatique","Métallurgie","Médical","Nautisme","Paramédical","Restauration","Sécurité","Textile","Tourisme","Transport","Urbanisme"]
        var catCells : Array<DropDownMenuCell>
        catCells = []
        
        for string in toutesCat  {
            
            let cell = DropDownMenuCell()
            cell.textLabel!.text = string
            cell.menuAction = #selector(ViewController.choose(_:))
            cell.menuTarget = self
            if currentChoice == cell.textLabel!.text {
                cell.accessoryType = .checkmark
            }
            
            catCells.append(cell)
        }
        
        navigationBarMenu.menuCells = catCells
        navigationBarMenu.selectMenuCell(catCells.first!)
    	
    	// If we set the container to the controller view, the value must be set
    	// on the hidden content offset (not the visible one)
    	navigationBarMenu.visibleContentOffset =
    		navigationController!.navigationBar.frame.size.height + statusBarHeight()
    
    	// For a simple gray overlay in background
    	navigationBarMenu.backgroundView = UIView(frame: navigationBarMenu.bounds)
    	navigationBarMenu.backgroundView!.backgroundColor = UIColor.black
    	navigationBarMenu.backgroundAlpha = 0.7
    }`
    

    Screenshot :

    simulator screen shot on iPhone 7+

    opened by rico237 9
  • Drop Down Menu does not work in a popup

    Drop Down Menu does not work in a popup

    I have a issue when using the drop down menu in pop up and choosing a cell: I get the following error:

    screen shot 2017-08-24 at 4 10 31 pm

    Could you please provide a solution for it? Thank you in advance

    help wanted 
    opened by hamededini 6
  • Add customisation

    Add customisation

    This library is great, I've added a few configuration so it can fit into more design.

    • support row height customisation
    • make iconSize open to change
    • added title view configuration to customise menu up/down images
    • use size of menuDownImageView to set the size of ImageView, as custom image would have different sizes

    cheers.

    opened by nicholas-jomo 6
  • Title view collapses on the size of the first item.

    Title view collapses on the size of the first item.

    Hello, I've got an issue with the DropDownTitleView, it seems to fix it's size to the first assigned text.

    Even when constructing the view with a way to large frame I run into the same issue:

    DropDownTitleView(frame: CGRect(x: 0, y: 0, width: 400, height: 40))
    

    Images say more than words:

    Do you have a recommendation how to solve this issue?

    And a big thank you for the work you have put into this UI component.

    opened by mario-deluna 5
  • Table view not filled

    Table view not filled

    Hi, I fetch my data asynchronously and I fill the menuCells once I have it. My issue is the table view is not filled or may be is not displayed.

    Have you a solution ?

    bug 
    opened by grifas 5
  • Inheritance is forbidden

    Inheritance is forbidden

    required public init?(coder aDecoder: NSCoder) {
    	    fatalError("init(coder:) has not been implemented")
    	}
    

    wtf? I want to create a cell with xib file but I can't because of this useless code

    enhancement 
    opened by gerchicov-bp 4
  • Pod Build fails with current version of Swift

    Pod Build fails with current version of Swift

    Integrated the framework via Cocoapods. When I build my project this framework lists 20 or so errors. Would love to use this library, could you guys take a look and build it with the latest Xcode and Swift, and update the pod spec to use the latest version? Thanks. @qmathe @grifas

    opened by james-ff 3
  • Default selecting a row.

    Default selecting a row.

    Don't know whether this is related to the repository itself, however i believe that this feature would be useful.

    i've tried with following code, but does not seem to work.

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    
        let rowToSelect = IndexPath.init(row: 0, section: 0)
    
        navigationBarMenu.menuView.selectRow(at: rowToSelect, animated: false, scrollPosition: .none)
    
        // Calling manually to the delegate method
        navigationBarMenu.tableView(navigationBarMenu.menuView, didSelectRowAt: rowToSelect)
    }
    
    opened by Fredehagelund92 3
  • issue when working with MBProgressHUD

    issue when working with MBProgressHUD

    on cell.menuAction selector like this: func choose(_ sender: AnyObject) { titleView.toggleMenu() showHud(); hideHud(); } and the dropMenu animation will be strange.

    help wanted 
    opened by 1037390459 2
  • Check for empty cells is missing from pod install version in DropDownMenu class

    Check for empty cells is missing from pod install version in DropDownMenu class

    Hello,

    Thanks for nice lib. Yesterday I have faced following issue. In the GitHub version in master branch I have noticed that in DropDownMenu.swift file line 156 there is if statement for checking empty cell case before scrolling tableview:

    	contentView.frame.size.height = menuView.frame.height
    
    	// Reset scroll view content offset after rotation
    	if menuView.visibleCells.isEmpty {
    			return
    		}
    	menuView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
    

    But when I have pod install on my project I notice that this statement is missing from source code and it cause exception at runtime when DropDownMenu does not have any cell.

    Could you please help me get last version via pod install?

    My podfile is: pod 'DropDownMenuKit'

    opened by hamtiko 2
  • Menu and container not released

    Menu and container not released

    Variable 'container' in DropDownMenu.swift (line 23) is strong reference, therefore when container is removed from view hierarhy it maintains referenced by DropDownMenu and can not be destroyed. Solution: make container weak reference and perform necessary checks in methods show, hide and visibleContentOffset.didSet

    opened by IngwarSkjold 2
  • Error retrieving icon from bundle

    Error retrieving icon from bundle

    Hi,

    in some cases this pod can raise an error (and cause a crash) when retrieving an icon from the xcassets file.

    This happens when you subclass DropDownTitleView, therefore the pod can't retrieve the bundle in which the icon is supposed to be and finally crashes trying to unwrap a nil value.

    The fix is very easy: https://github.com/DigitalGoal-Ltd/DropDownMenuKit/commit/e98532c875641325fae56fa5c48ade2cd8cc51a8

    bug 
    opened by PasqualePuzio 1
  • Do you have an example code for the 'sort' drop down you show in the screen shot?

    Do you have an example code for the 'sort' drop down you show in the screen shot?

    the version where there is up and down arrows and also the segment where you select what you want to sort on? Its spot on what I'm looking for.

    Thanks

    help wanted 
    opened by netsmith 2
  • Feature request - overlay view in outer view controller

    Feature request - overlay view in outer view controller

    In my case UITabBarController is root. So if I add this control into inner navigation bar then it won't overlay UITabBar and UITabBarController is still clickable

    enhancement 
    opened by gerchicov-bp 2
Releases(0.9)
  • 0.9(May 14, 2019)

Owner
Quentin Mathé
Freelance iOS and Mac developer. Free software hacker on Étoilé and CoreObject. Working on Placeboard, a mobile app to remember and share places.
Quentin Mathé
An iOS drop down menu with pretty animation and easy to customize.

IGLDropDownMenu An iOS drop down menu with pretty animation. Screenshot How To Use Use CocoaPods: pod 'IGLDropDownMenu' Manual Install: Just drap the

Galvin Li 1.2k Dec 27, 2022
A Material Design drop down for iOS

A Material Design drop down for iOS written in Swift. Demo Do pod try DropDown in your console and run the project to try a demo. To install CocoaPods

AssistoLab 2.3k Jan 1, 2023
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
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
PagingKit provides customizable menu UI. It has more flexible layout and design than the other libraries.

PagingKit provides customizable menu & content UI. It has more flexible layout and design than the other libraries. What's this? There are many librar

Kazuhiro Hayashi 1.3k Jan 9, 2023
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
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
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
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
Steven Troughton-Smith 57 Dec 6, 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
A simple customizable side menu written in SwiftUI.

NSideMenu Description A simple customizable side menu written in SwiftUI. Give a Star! ⭐ Feel free to request an issue on github if you find bugs or r

null 5 Oct 10, 2022
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Anatoliy Voropay 22 Dec 27, 2022
iOS Interactive Side Menu written in Swift.

Interactive Side Menu A customizable, interactive, auto expanding and collapsing side menu for iOS written in Swift. Here are some of the ways Interac

Handsome 706 Dec 15, 2022
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.

SlideMenuControllerSwift iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app. Installation CocoaPods pod 'SlideMenuControllerSwift' Carth

Yuji Hato 3.3k Dec 29, 2022
ExpandingMenu is menu button for iOS written in Swift.

ExpandingMenu ExpandingMenu is written in Swift. Requirements iOS 8.0+ Xcode 10.0+ Swift 3.x+ Installation CocoaPods You can install CocoaPods with th

null 454 Dec 7, 2022
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift

Persei Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift! Made in Yalantis. Check this project on Dribbble Check th

Yalantis 3.4k Dec 14, 2022
A side menu controller written in Swift for iOS

Description SideMenuController is a custom container view controller written in Swift which will display the main content within a center panel and th

Teo 1.2k Dec 29, 2022