用来给看的人更好的区分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";
}
}