Available thru Cocoapods
Latest 0.0.1
Homepage https://github.com/sudeepjaiswal/ASJDropDownMenu
License MIT

iOS doesn’t have a drop down menu by default. Developers are supposed to use the UIPickerView for similar functionality. Project design constraints may sometimes however necessitate the use of such a menu. This class is a subclass of UIView that has a UITableView embedded in it. It provides the functionality needed to show a drop down menu below a UITextField and is customisable using various properties.

Installation

Cocoapods is the preferred way to install this library. Add this command to your Podfile:

pod 'ASJDropDownMenu'

Usage

Creating one is simple. The show method has a completion block which returns the selected item. You may hide the drop down there and then:

ASJDropDownMenu *dropDownMenu = [[ASJDropDownMenu alloc] initWithTextField:aTextField];
dropDownMenu.menuItems = anArrayOfASJDropDownMenuItems;
[dropDown showMenuWithCompletion:^(ASJDropDownMenu *dropDownMenu, ASJDropDownMenuItem *menuItem, NSUInteger index) {
  [dropDownMenu hideMenu];
}];

The menu items need to be on type ASJDropDownMenuItems. Constructor methods are provided to generate them. Just attach an array of these to your drop down menu instance.

ASJDropDownMenuItem *itemWithTitle = [ASJDropDownMenuItem itemWithTitle:@"a title"];
anInstanceOfDropDownMenu.menuItems = @[itemWithTitle, anotherItemWithTitle];
ASJDropDownMenuItem *itemWithSubtitle = [ASJDropDownMenuItem itemWithTitle:@"a title" subtitle:@"a subtitle"];
anInstanceOfDropDownMenu.menuItems = @[itemWithSubtitle, anotherItemWithSubitle];

alt tag

To-do

  • Animation to open and close
  • Provision to add images
  • Provision to close on item selection
  • Option to open the drop down in up or down direction
  • Move the screen to accomodate the drawer when keyboard shows

License

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

Latest podspec

{
    "name": "ASJDropDownMenu",
    "version": "0.0.1",
    "platforms": {
        "ios": "7.0"
    },
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/sudeepjaiswal/ASJDropDownMenu",
    "authors": {
        "Sudeep Jaiswal": "[email protected]"
    },
    "summary": "A drop down menu with embedded TableView to list options",
    "source": {
        "git": "https://github.com/sudeepjaiswal/ASJDropDownMenu.git",
        "tag": "0.0.1"
    },
    "source_files": "ASJDropDownMenu/ASJDropDownMenu.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This