Skip to content

bingxue314159/TYGSelectMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TYGSelectMenu

功能说明

快速的创建下拉多级菜单,无论多少级都可以!但目前只建议最多三级!

截图

demo1

代码

数据的初始化

//初始化一级目录数据
TYGSelectMenu *menuLevel1 = [[TYGSelectMenu alloc] init];
    for (int i = 0; i < 10; i++) {
        TYGSelectMenuEntity *menu1 = [[TYGSelectMenuEntity alloc] init];
        menu1.title = [NSString stringWithFormat:@"%d",i];
        [menuLevel1 addChildSelectMenu:menu1 forParent:nil];
}
//初始化二级目录数据
TYGSelectMenu *menuLevel2 = [[TYGSelectMenu alloc] init];
for (int i = 0; i < 10; i++) {
    TYGSelectMenuEntity *menu1 = [[TYGSelectMenuEntity alloc] init];
    menu1.title = [NSString stringWithFormat:@"%d",i];
    [menuLevel2 addChildSelectMenu:menu1 forParent:nil];
    for (int j = 0; j < 15; j++) {
        TYGSelectMenuEntity *menu2 = [[TYGSelectMenuEntity alloc] init];
        menu2.title = [NSString stringWithFormat:@"%@-%d",menu1.title,j];
        [menuLevel2 addChildSelectMenu:menu2 forParent:menu1];
    }
}
//初始化三级目录数  
TYGSelectMenu *menuLevel3 = [[TYGSelectMenu alloc] init];
for (int i = 0; i < 10; i++) {
    TYGSelectMenuEntity *menu1 = [[TYGSelectMenuEntity alloc] init];
    menu1.title = [NSString stringWithFormat:@"%d",i];
    [menuLevel3 addChildSelectMenu:menu1 forParent:nil];
    for (int j = 0; j < 15; j++) {
        TYGSelectMenuEntity *menu2 = [[TYGSelectMenuEntity alloc] init];
        menu2.title = [NSString stringWithFormat:@"%@-%d",menu1.title,j];
        [menuLevel3 addChildSelectMenu:menu2 forParent:menu1];
        for (int x = 0; x < 20; x++) {
            TYGSelectMenuEntity *menu3 = [[TYGSelectMenuEntity alloc] init];
            menu3.title = [NSString stringWithFormat:@"%@-%d",menu2.title,x];
            [menuLevel3 addChildSelectMenu:menu3 forParent:menu2];
        }
    }
}

显示及回调

//显示并隐藏其它
[menuLevel1 showFromView:sender];
[menuLevel2 disMiss];
[menuLevel3 disMiss];   
//block回调
[menuLevel1 selectAtMenu:^(NSMutableArray *selectedMenuArray) {
    NSMutableString *title = [NSMutableString string];
    for (TYGSelectMenuEntity *tempMenu in selectedMenuArray) {
        [title appendString:[NSString stringWithFormat:@"%ld",(long)tempMenu.id]];
    }
    [sender setTitle:title forState:UIControlStateNormal];
}];

问题反馈

如果你在使用过程中发现了BUG,你可以这样联系到我:
Email:bingxue314159#163.com(把#换成@)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published