UITabelView全局表头和每个分区的表头和大小,设置区分表头的标题

 

用来给看的人更好的区分UITabelView 的表头 表尾  分区表头 

纯手打,请勿抄袭

 

 

设置整个tabelView的表头 和 表尾

UIView *headerView = [UIView alloc]initWithFrame:CGRectMake(0,0,0,100);

headerView.backgroundView = [UIColor redColor];

tabelView.tabelHeaderView = headerView;

[headerView release];

 

 

// 表头  只有height 能改变

// 表尾 只有X  和height 能改变

 

UIView *footerView = [UIView alloc]initWithFrame:CGRectMake(0,0,0,100);

footerView.backgroundColor = [UIColor whiteColor];

tabelView.tabelFooterView = footerView;

[footerView release];

[self.view addSubview:tabelView];

[tabelView release];

 

// 设置每个分区的表头和表尾

-  (UIView *)tabelView:(UITabelView *)tabelView viewForHeaderInSection:(NSInteger )section

{

       UIView *headerView =[ [UIView alloc]initWithFrame:CGRectMake(0,0,100,100)];

       hearderView.backgroundColor = [UIColor blackColor];

       return [headerView autorelease];

}

 

- (UIView *)tabelView:(UITabelView *)tabelView viewFooterInSection:(NSInteger)section

{

   UIView *footerView =[ [UIView alloc]initWithFrame:CGRectMake:(0, 0, 100,100)];

   footerView.backgroundColor = [UIColor blueColor];

   return [footerView autorelease];

}

 

//  设置分区表头 和 表尾的高度

-  (CGFloat)tabelView:(UITabelView *)tabelView heightForHeaderInSection:(NSInteger)section

{

       return  20;

}

 

- (CGFloat)tabelView:(UITabelView *)tabelView heightForFooterInSection:(NSInteger)section

{

      return 20;

}

 

// 设置区分表头的标题

- (NSString *)tabelView:(UITabelView *)tabelView titleForHeaderInSection:(NSInteger)section

{

        if (section == 0){

           return @"A";

        }else if (section == 1){

       return @"B";

       }else{

         return @"C";

      }

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值