download KPDropMenu from Github: Click Here
dropDownViewController.h
#import <UIKit/UIKit.h>
#import "KPDropMenu.h"
@interface dropDownViewController : UIViewController
@property (strong, nonatomic) IBOutlet KPDropMenu *drop;
@end
dropDownViewController.m
#import "dropDownViewController.h"
@interface dropDownViewController ()<KPDropMenuDelegate>
@end
@implementation dropDownViewController
- (void)viewDidLoad {
[super viewDidLoad];
_drop.items = @[@"Apple", @"Grapes", @"Cherry", @"Pineapple", @"Mango", @"Orange"];
_drop.itemsIDs = @[@"0", @"1", @"2", @"3", @"4", @"5"];
_drop.itemsFont = [UIFont fontWithName:@"Helvetica-Regular" size:12.0];
_drop.titleTextAlignment = NSTextAlignmentCenter;
_drop.delegate = self;
/* Adding Menu Programatically*/
KPDropMenu *dropNew = [[KPDropMenu alloc] initWithFrame:CGRectMake(8, 250, 150, 50)];
dropNew.delegate = self;
dropNew.items = @[@"Apple", @"Grapes", @"Cherry", @"Pineapple", @"Mango", @"Orange"];
dropNew.title = @"Select Again";
dropNew.itemsFont = [UIFont fontWithName:@"Helvetica-Regular" size:12.0];
dropNew.titleTextAlignment = NSTextAlignmentCenter;
dropNew.DirectionDown = NO;
[self.view addSubview:dropNew];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - KPDropMenu Delegate Methods
-(void)didSelectItem : (KPDropMenu *) dropMenu atIndex : (int) atIntedex{
if(dropMenu == _drop)
NSLog(@"%@ with TAG : %ld", dropMenu.items[atIntedex], (long)dropMenu.tag);
else
NSLog(@"%@", dropMenu.items[atIntedex]);
}
-(void)didShow:(KPDropMenu *)dropMenu{
NSLog(@"didShow");
}
-(void)didHide:(KPDropMenu *)dropMenu{
NSLog(@"didHide");
}
@end
////City is UIView
Sign up here with your email
3 comments
Write commentsThanks for sharing this code. This is working.
ReplyEmu4IOS For IOS
Is it applicable inside tableview
ReplyConversionConversion EmoticonEmoticon