代码库> 列表> 列表单元格下拉菜单
列表单元格下拉菜单
关注
查看次数:3608 下载次数:10
上传时间:2015-08-30 大小:
[upload=1] /**
*  构建下拉视图
*/
- (void)buildMenuView
{
    //避免多次绘制下拉菜单
    if (self.isAlreadyDrawMenu)
    {
        return;
    }
    
    //构建菜单
    self.menuItemDataSourceArray = [NSMutableArray arrayWithCapacity:0];
    if ([self.dataSource respondsToSelector:@selector(dataSourceForMenuItem)])
    {
        self.menuItemDataSourceArray = [self.dataSource dataSourceForMenuItem];
        
        __weak MenuTableViewCell *weakSelf = self;
        [self.menuItemDataSourceArray enumerateObjectsUsingBlock:^(MenuItemModel *menuItemModel, NSUInteger idx, BOOL *stop) {
            
            if (idx >= MAX_ITEM_COUNT)
            {
                //下拉菜单的item超过最大数(MAX_ITEM_COUNT:5)的时候就不绘制,可以自定义下拉菜单个数
                return ;
            }
            
            CGRect menuItemRect = CGRectMake(MENU_ITEM_SPACE + (MENU_ITEM_SPACE + MENU_ITEM_WHIDE) * idx, 0, MENU_ITEM_WHIDE, MENU_ITEM_HEIGHT);
            LYButton *menuItemButton = [[LYButton alloc] initWithFrame:menuItemRect model:menuItemModel];
            menuItemButton.tag = idx;
            [menuItemButton addTarget:self
                               action:@selector(menuItemClick:)
                     forControlEvents:UIControlEventTouchUpInside];
            [weakSelf.menuView addSubview:menuItemButton];
        }];
    }
    
    self.isAlreadyDrawMenu = YES;
}


连接见:http://git.oschina.net/LYLHF/UITableViewMenu中附件
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0


下载过该代码的还下载了
综合评论
提示
sina weixin mail 回到顶部