EEJSelectMenu是一个针对iOS的单选菜单。
该项目允许实现具有不同数量按钮和不同动画出现的菜单。
它将根据设备屏幕大小调整按钮大小!
只需提供按钮名称,菜单将负责按钮的数量和布局!
将Classes/
文件夹中的文件添加到您的项目中
将头文件导入到您的源代码中
#import "EEJSelectMenu.h"
初始化器
-initWithButtons:animationStyle:color:andDelegate
-initWithButtons:animationStyle:colors
创建EEJSelectMenu的实例,并提供按钮名称和颜色
NSArray *buttonNames = @[@"ONE",@"TWO",@"THREE",@"FOUR"];
EEJSelectMenu *menu = [[EEJSelectMenu alloc]initWithButtons:buttonNames
animationStyle:EEJAnimationStyleFadeIn
color:[UIColor darkGrayColor]
andDelegate:self];
[self presentViewController:menu animated:NO completion:nil];
对于多色菜单,使用此初始化器
NSArray *buttonNames = @[@"ONE",@"TWO",@"THREE",@"FOUR"];
EEJSelectMenu *menu = [[EEJSelectMenu alloc]initWithButtons:buttonNames
animationStyle:EEJAnimationStyleFadeIn
colors:@[[UIColor redColor],[UIColor greenColor]
[UIColor blueColor],[UIColor orangeColor]] ];
menu.delegate = self;
[self presentViewController:menu animated:NO completion:nil];
或简单初始化器,使用默认颜色
EEJSelectMenu *menu = [[EEJSelectMenu alloc]init];
menu.buttonNames = @[@"ONE",@"TWO",@"THREE",@"FOUR"];
menu.animationStyle = EJAnimationStyleAlternate;
menu.delegate = self;
// default color is light blue
[self presentViewController:menu animated:NO completion:nil];
menu.animationStyle = EJAnimationStyleFadeIn; // default
其他可用的动画样式
EJAnimationStyleWiden
EJAnimationStyleScale
EJAnimationStyleMoveInFromLeft
EJAnimationStyleMoveInFromRight
EJAnimationStyleAlternate
EEJSelectMenu提供两种委托方法
-(void)EJSelectMenuButtonWasPressedWithTitle:(NSString *)title;
-(void)EJSelectMenuButtonWasPressedWithTag:(long)tag;
// button tags start at 100 and increment by one for each
更改选中按钮颜色(默认:紫色)
menu.selectedButtonColor = [UIColor blueColor];
更改菜单背景颜色(默认:白色)
menu.menuBackgroundColor = [UIColor redColor];
EEJSelectMenu 在 MIT 许可下发布。有关详情,请参阅 LICENSE。