🔻 Dropdown Menu for iOS with many customizable parameters to suit any needs

Overview

MKDropdownMenu

Build Status Version License Platform

Dropdown Menu for iOS with many customizable parameters to suit any needs.

Inspired by UIPickerView.

MKDropdownMenu

MKDropdownMenu

Installation

CocoaPods

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

pod 'MKDropdownMenu'

Manually

  • Add MKDropdownMenu folder to your Xcode project.
  • #import "MKDropdownMenu.h" in your code.

Usage

See the example Xcode project.

Basic setup

Create the MKDropdownMenu instance and add it as a subview to your view. Set the dataSource and delegate properties to your view controller implementing MKDropdownMenuDataSource and MKDropdownMenuDelegate protocols.

MKDropdownMenu *dropdownMenu = [[MKDropdownMenu alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
dropdownMenu.dataSource = self;
dropdownMenu.delegate = self;
[self.view addSubview:dropdownMenu];

Interface Builder

You can also set up the MKDropdownMenu in Interface Builder.

  • Add a UIView and set its class to MKDropdownMenu in the Identity inspector.
  • Connect the dataSource and delegate outlets to your view controller.

Populating the data

The MKDropdownMenuDataSource and MKDropdownMenuDelegate protocols APIs are inspired by the UIPickerView interface, so most of the methods should be familiar if you used it before.

Implement the following dataSource methods:

- (NSInteger)numberOfComponentsInDropdownMenu:(MKDropdownMenu *)dropdownMenu;
- (NSInteger)dropdownMenu:(MKDropdownMenu *)dropdownMenu numberOfRowsInComponent:(NSInteger)component;

and the delegate methods that suit your needs. The most simple way to get started is to provide the titles for the header components and the rows in the following delagate methods:

- (NSString *)dropdownMenu:(MKDropdownMenu *)dropdownMenu titleForComponent:(NSInteger)component;
- (NSString *)dropdownMenu:(MKDropdownMenu *)dropdownMenu titleForRow:(NSInteger)row forComponent:(NSInteger)component;

You can also provide an NSAttributedString or custom UIView as the display data for MKDropdownMenu in the corresponding delegate methods.

Customizations

The appearance and behavior of the MKDropdownMenu can be customized by setting its property values or implementing the corresponding delegate methods.

The default menu appearance can be customized throughout the app using the available UI_APPEARANCE_SELECTOR properties.

Requirements

  • iOS 8+
  • Xcode 8+

License

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

Comments
  • Issue with dropdownShowsBorder and setSeperatorColor

    Issue with dropdownShowsBorder and setSeperatorColor

    Hi, the border (in #6) works pretty fine, except that something with dropdownShowsBorder == YES in line 752~756:

    if (self.showsBorder && indexPath.row == self.rowsCount - 1) {
            cell.separatorInset = UIEdgeInsetsMake(0, CGRectGetWidth(tableView.bounds), 0, 0);
    } else {
            cell.separatorInset = UIEdgeInsetsZero;
    }
    

    I'm not sure why you have to set seperatorInset to the last row when showing border, but it seems to crop the data inside the cell and my label turn from any to "..." string. I've tried comment out everything except cell.separatorInset = UIEdgeInsetsZero; and it turns out fine.

    Also, there seems to have a problem with rowSeparatorColor, as it affect the border color but doesn't to the seperator (image below). image

    Though I agree that the border color should be the same as the separator's, please do something with these, thanks!!! (I was checking in ios 10.2)

    bug 
    opened by EddieLukeAtmey 15
  • componentSeparatorColor doesnt' work

    componentSeparatorColor doesnt' work

    dropdown.rowSeparatorColor = UIColor.blackColor()
    dropdown.componentSeparatorColor = UIColor.blackColor()
    

    does not change color of components. As you can see on screenshot , only first row changes color to black.

    screen shot 2016-07-19 at 17 57 36

    opened by skywinder 9
  • MKDropdownMenu in UIScrollView

    MKDropdownMenu in UIScrollView

    Выпадающие элементы не прикреплены к заголовку. В UIScrollView появляется проблема - элементы висят на месте, заголовок движется. img_1119 img_1120 Вы можете исправить это? Заранее спасибо!

    opened by ghost 9
  • I'd like to make a dimmed background for the whole view

    I'd like to make a dimmed background for the whole view

    I've implemented your dropdown menu, subclass it as to fit my own theme. It works nice but there's something a little bit off when the drop down is not on top of a view (see image below)

    simulator screen shot 2016 09 07 14 20 38

    (Note: In the image I haven't set the presentingView to my popup, but I'll)

    Please guide me about how to make the whole view dimmed and tapable (to dismiss the dropDown), or make an update or anything. Currently, I'm disabling the dimmed background as a work around, but it still not receive the tapAction when tap above the dropDown.

    opened by EddieLukeAtmey 7
  • Menu does not respect UIViewTintAdjustmentModeDimmed

    Menu does not respect UIViewTintAdjustmentModeDimmed

    I currently don't see a way to change the menu's tintColor when it should be dimmed (UIViewTintAdjustmentModeDimmed, e.g., when an UIAlertView is presented).

    Due to this all my app's UI currently properly dims but the dropdown menu doesn't, which makes things look out of place (when collapsed, the title doesn't dim but the disclosureIndicator does, making even the menu itself inconsistent).

    Would it be possible to properly support tintColorDidChange within the class itself or is there a way around to do this now (e.g., using tintColorDidChange in the containing class and the refresh the menu)?

    enhancement 
    opened by ahndee 6
  • text cell size to fit problem?

    text cell size to fit problem?

    Hello, I run your example and change some text for row of table. Then got that problem: simulator screen shot - iphone 5s - 2017-11-11 at 00 35 25

    I think u used size to fit method to label text or something like that but i can not find the code. Plz help me how to make text become clipped like "đasadasdasd..." . Thanks # # @ @maxkonovalov @IvanivOleg

    opened by fukemy 4
  • Close 2 or more DropdownMenu on touch outside.

    Close 2 or more DropdownMenu on touch outside.

    Hello, I've tried modifying the code myself, but couldn't do it. Two issues:

    1. DropdownMenu doesn't close when tap outside of dropdown menu, it closes the dropdownMenu ONLY if the tap is "below" the DropdownMenu, if the tap is above, dropdownMenu remains.

    2. If I have 2 dropdownMenu 100px above each other, tapped on bottom's dropdownMenu opens the selection, and because of issue 1, and I tap on the above dropdownMenu, I have 2 expanded dropdownMenu stacking each other now. Is there anyway to fix this? If 2 dropdownMenus are expanded, and I tap on area that is above both dropdownMenu, they won't close..

    opened by jackywongcw 4
  • #21: Add show content above

    #21: Add show content above

    Please review and merge.

    Change:

    • Add new property.
    • Adjust scrollView content offset when presenting and dismiss.
    • If not scrollView && isShowAbove, keep original size instead of crop content's height.

    Future implement:

    • Make auto calculation to show content above or below.
    opened by EddieLukeAtmey 4
  • Add isComponentOpened method

    Add isComponentOpened method

    Hi, I would like to programming open menu by myself, like this.

    Usage:

    - (IBAction)buttonClick:(id)sender {
        if (![self.navBarMenu isComponentOpened]) {
            [self.navBarMenu openComponent:0 animated:YES];
        } else {
            [self.navBarMenu closeAllComponentsAnimated:YES];
        }
    }
    

    but I cannot have the status to determine it when open or close. so I add a method, please take a look, thanks.

    opened by j796160836 4
  • Drop down arrow image

    Drop down arrow image

    Hi everyone, I am trying to remove the drop down arrow completely without any luck. I tried to make an image 1X1 pixels with transparent background, a 1X1 pixels white image and nothing helps - it ignores it! If removing it can't be done, than putting a custom coloured arrow. Thanks!

    opened by CripyIce 3
  • How to dismiss menu when no select an item?

    How to dismiss menu when no select an item?

    Is there a way to dismiss the menu displayed, if the user didn't select an element of the dropdown menu? I'm observing that the view displayed like a blur responds to the tap and dismiss. But what happens when the tab is outside of this blur view? If i navigate to other view controller (with the dropdown displayed) my menu is moving with that new View Controller pushed.

    what i'm doing wrong? Thanks for your help, and congrats for your work.

    opened by polymorphia 3
  • No manifest file

    No manifest file

    In Xcode, it says MKDropdownMenu package is "passing," but when I run my app, build fails due to lack of Package.Swift manifest file. I think Facebook or Firebase is requiring me to switch from cocoapods to Swift Package Manager and modules because it removed users' ability to log in with Facebook - that's why I switched in the first place, but now app is broke.

    opened by caldwbr 0
  • Drop Down Height

    Drop Down Height

    Hello, I am facing one issue, Suppose the superview height is 60 and the array length is more then 3, then drop down height is decreased like below image

    Simulator Screen Shot - iPhone 12 Pro Max - 2021-08-23 at 14 08 56

    is it possible that if space is less then the drop down should so up.

    opened by nigamsiddhant 1
  • AccessibilityViewIsModel

    AccessibilityViewIsModel

    Currently when i have dropdown present in the superview, Accessibility inspector is not focusing on the dropdown elements.So how can i focus on dropdown elements alone when drop down is enabled? I tried with AccessibilityViewIsModel but i couldn’t find the prefect solution.

    opened by vijay-natarajan 0
  • Layout Error in iOS 11

    Layout Error in iOS 11

    set a MKDropdownMenu in VC1 NavigationBar TitileView, than nav push to VC2, than back to VC1. you can see that MKDropdownMenu layout error.

    in your Demo project, MKDropdownMenu is lose, can't find it

    000

    opened by vvard3n 5
Releases(1.4)
Owner
Max Konovalov
iOS Developer 👨🏻‍💻
Max Konovalov
✨ 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
A simple dropdown menu component for iPhone

AZDropdownMenu AZDropdownMenu is a simple dropdown menu component that supports Swift. Screenshots Code used in the screencast are included in the bun

Wu 194 Nov 14, 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
This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit.

CatalystToolbarMenuButton This is a simple Mac Catalyst example showcasing how to build a dropdown menu toolbar button using AppKit. There are ways to

Steven Troughton-Smith 24 Dec 8, 2022
Menubar app to remove link tracking parameters automatically

TrackerZapper Website and more info TrackerZapper is a Mac app that sits in your menubar and silently removes tracking parameters from any links you c

Robb Knight 280 Jan 2, 2023
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
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
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
Slide-Menu - A Simple Slide Menu With Swift

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

Kirill 0 Jan 8, 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
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
A fully customizable popup style menu for iOS 😎

Guide Check out the documentation and guides for details on how to use. (Available languages:) English 简体中文 What's a better way to know what PopMenu o

Cali Castle 1.5k Dec 30, 2022
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
A paging view controller with a highly customizable menu ✨

Getting Started | Customization | Installation Features Parchment lets you page between view controllers while showing any type of generic indicator t

Martin Rechsteiner 3k Jan 8, 2023
Animated side menu with customizable UI

Side Menu Animated side menu with customizable UI. Made in Yalantis. Check this project on dribbble. Check this project on Behance. Requirements iOS 7

Yalantis 2.7k Dec 27, 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