tabLeview的静态分组使用


- (UITableView *)tableView
{
    if(!_tableView)
    {
        _tableView = [[UITableView alloc] initWithFrame:nckR(0, 0, MW, MH - 92)];
        _tableView.backgroundColor = [UIColor greenColor];
        _tableView.dataSource = self;
        
        _tableView.delegate = self;
        
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
                    }
    
    return _tableView;
}



#pragma mark-
#pragma mark tableView的代理方法


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectionIndex
{
    
    return 30;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
        return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return 5;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionIndex
{
    if (sectionIndex == 0)
    {
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
    view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
    label.text = @"女士";
    label.font = [UIFont systemFontOfSize:15];
    label.textColor = [UIColor whiteColor];
    label.backgroundColor = [UIColor clearColor];
    [label sizeToFit];
    [view addSubview:label];
    
    return view;
}

  else  if (sectionIndex == 1)
    {
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
        view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
        label.text = @"男士";
        label.font = [UIFont systemFontOfSize:15];
        label.textColor = [UIColor whiteColor];
        label.backgroundColor = [UIColor clearColor];
        [label sizeToFit];
        [view addSubview:label];
        
        return view;
    }

        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 34)];
        view.backgroundColor = [UIColor colorWithRed:167/255.0f green:167/255.0f blue:167/255.0f alpha:0.6f];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 0, 0)];
        label.text = @"生活";
        label.font = [UIFont systemFontOfSize:15];
        label.textColor = [UIColor whiteColor];
        label.backgroundColor = [UIColor clearColor];
        [label sizeToFit];
        [view addSubview:label];
        
        return view;
    


}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchCell"];
    
    if (!cell) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"SearchCell"];
       
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        if (indexPath.section ==0) {
            
            NSArray * woman = @[@"COAT 上衣",
                                  @"THE TROUSERS 裙",
                                  @"THE SKIRT 裤",
                                  @"UNSER WEAR 内衣",
                                  @"SOCKS 袜",
                                  @"HAT 帽",@"SHOES 鞋"];
            cell.textLabel.text = woman[indexPath.row];
            
            
        }
      
       else if (indexPath.section == 1) {
            
           NSArray * man = @[@"COAT 上衣",@"THE TROUSERS 裙",@"THESKIRT裤",@"UNSER WEAR 内衣", @"SOCKS 袜", @"HAT 帽",@"SHOES 鞋"];
     
           cell.textLabel.text =man[indexPath.row];
        
       }
       else if (indexPath.section ==2){
           NSArray * live =  @[@"COAT 上衣",
                               @"THE TROUSERS 裙",
                               @"THE SKIRT 裤",
                               @"UNSER WEAR 内衣",
                               @"SOCKS 袜",
                               @"HAT 帽",@"SHOES 鞋"];
           cell.textLabel.text = live[indexPath.row];
           
       }

        
    }
    
    return cell;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值