使用以下代码作为答案
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *tempView=[[[UIView alloc]initWithFrame:CGRectMake(0,0,300,44)]autorelease];
tempView.backgroundColor=[UIColor redColor];
UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,300,44)];
tempLabel.backgroundColor=[UIColor clearColor];
tempLabel.text=@"MY HEADER";
[tempView addSubview: tempLabel];
[tempLabel release];
return tempView;
}
Run Code Online (Sandbox Code Playgroud)
这将为您提供一个redColor标头.根据您的要求更改颜色......
编辑(根据苛刻):
由于标题中的视图将与您的第一个单元格重叠,因此请增加标题的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}
Run Code Online (Sandbox Code Playgroud)
快乐的编码........
| 归档时间: |
|
| 查看次数: |
4696 次 |
| 最近记录: |