Code Monkey home page Code Monkey logo

mkdropdownmenu's Introduction

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.

mkdropdownmenu's People

Contributors

maxkonovalov avatar nsneil avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.