A pulldown menu for all iOS devices.
The pulldown menu supports both navigation controllers and views, users can either pull it down or activate by tapping a button.
.h
#import "PulldownMenu.h"
@interface MasterNavigationController : UINavigationController<PulldownMenuDelegate> {
PulldownMenu *pulldownMenu;
}
@property (nonatomic, retain) PulldownMenu *pulldownMenu;
@end
.m
- (void)viewDidLoad
{
[super viewDidLoad];
pulldownMenu = [[PulldownMenu alloc] initWithNavigationController:self];
[self.view insertSubview:pulldownMenu belowSubview:self.navigationBar];
[pulldownMenu insertButton:@"Menu Item 1"];
[pulldownMenu insertButton:@"Menu Item 2"];
[pulldownMenu insertButton:@"Menu Item 3"];
pulldownMenu.delegate = self;
[pulldownMenu loadMenu];
}
.h
#import "PulldownMenu.h"
@interface MainViewController : UIViewController<PulldownMenuDelegate, UIScrollViewDelegate> {
PulldownMenu *pulldownMenu;
}
.m
- (void)viewDidLoad
{
[super viewDidLoad];
pulldownMenu = [[PulldownMenu alloc] initWithView:self.view];
[self.view addSubview:pulldownMenu];
[pulldownMenu insertButton:@"Menu Item 1"];
[pulldownMenu insertButton:@"Menu Item 2"];
[pulldownMenu insertButton:@"Menu Item 3"];
pulldownMenu.delegate = self;
[pulldownMenu loadMenu];
}
- (IBAction)menuTap:(id)sender {
[pulldownMenu animateDropDown];
}
The component fires 2 events, #1 when a menu item is selected and #2 when the pull down is fully animated.
-(void)menuItemSelected:(NSIndexPath *)indexPath
{
NSLog(@"%d",indexPath.item);
}
-(void)pullDownAnimated:(BOOL)open
{
if (open)
{
NSLog(@"Pull down menu open!");
}
else
{
NSLog(@"Pull down menu closed!");
}
}
The pull down/up animation can be called on demand
From a view inside a navigation controller:
[((MasterNavigationController *)self.navigationController).pulldownMenu animateDropDown];
From a view
[pulldownMenu animateDropDown];
Apart from having both table view and handle exposed, a number of styling properties are available out of the box.
cellHeight = 60;
handleHeight = 15;
animationDuration = 0.3f;
topMarginPortrait = 0;
topMarginLandscape = 0;
cellColor = [UIColor grayColor];
cellSelectedColor = [UIColor blackColor];
cellFont = [UIFont fontWithName:@"GillSans-Bold" size:19.0f];
cellTextColor = [UIColor whiteColor];
cellSelectionStyle = UITableViewCellSelectionStyleDefault;