您的位置:首页 > 其它

tableview设置header

2015-09-21 13:09 274 查看
1,在为uitableview设置分区标题时,需要用到两个方法。如下

#pragma mark setTitle
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return 50;
}
return 30;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect frameRect = CGRectMake(0, 0, 100, 40);
UILabel *label = [[[UILabel alloc] initWithFrame:frameRect] autorelease];
label.text=@"myTitle";
return label;



}


其中title若返回label时,一定要制定label的大小,不然显示不出来,因为label默认的大小是0.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: