它是由兩部分組成的,上一個section的footer和下一個section的header。通過以下代碼就很明顯
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *view = [[UIView alloc]init]; view.frame = CGRectMake(0, 0, ScreenW, 20); UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 20)]; label.center = CGPointMake(ScreenW/2, 20/2); label.font = [UIFont systemFontOfSize:12]; label.backgroundColor = [UIColor redColor]; label.textAlignment = NSTextAlignmentCenter; [view addSubview:label]; if (section == 0) { label.text = @"最后更新時間:"; }else {
label.text =@"配置信息"; } return view; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = [[UIView alloc]init]; view.frame = CGRectMake(0, 0, ScreenW, 20); UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 20)]; label.center = CGPointMake(ScreenW/2, 20/2); label.font = [UIFont systemFontOfSize:12]; label.backgroundColor = [UIColor blueColor]; label.textAlignment = NSTextAlignmentCenter; [view addSubview:label]; return view; }
若想去掉section的footer,僅設置:應將其高度設為比1小很多,但不為0的值,才會有效果
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.001f; }