Skip to content

AsilJay/MJDDropDownMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

##A MJDDropDownMenu Guide

  • Introduction A simple library to show a dropdown menu . You can decide the columns of items to be displayed, where to display, just by giving the proper argument(s). The items ( I use buttons, you can make your own choice by edit the source code, if you like )could respond to click events by using delegate. What's more, there is a little animation when the menu comes out or dismiss.
  • Usage

    3 steps

    • Set an NSArray (or mutable one) to save the models. In the demo, the model is defined in the MJDDropDownMenuItem class.
    @property (nonatomic, strong) NSMutableArray *items;
    • Set a strong property to save a menu object.
     @property (nonatomic, strong) MJDDropDownMenu *menu;
    • Lazy load both properties above, for we need just one copy of them in memory. Remenber to fill the 'items' array with items you create. If you want the items to resond to clicks, set the controller as the menu's delegate in the lazy load.
    - (NSMutableArray *)items{
       if (!_items) {
           _items = [NSMutableArray array];
           for (int i = 0; i < MenuItems; i++){
               MJDDropDownMenuItem *item = [MJDDropDownMenuItem itemWithTitle:@"Hello" image:[UIImage imageNamed:@"red"]];
               [_items addObject:item];
           }
       }
       return _items;
    }
  • Implement the responding method of a button, or whatever subclass of an UIResponder, by which the menu comes out.

  - (IBAction)showMenu:(id)sender {
     if (self.menu.isMenuVisible) {
         [self.menu hide];
         self.menu = nil;   
     }else{
         [self.menu show];
     }
 }
  • Implement the delegate method to respond to the items' action.
  #pragma mark - ***** MJDDropDownMenuDelegate *****
  - (void)dropDownMenu:(MJDDropDownMenu *)menu clickedBtn:(UIButton *)btn{
         NSLog(@"clicked menuButton - %ld",btn.tag);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors