我收到了一个组风格表的应用程序。自定义表头部分
我尝试定制表头部分:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
UILabel *userName = [[UILabel alloc] initWithFrame:CGRectMake (0,0,200,30)];
if (section != 0)userName.text = @"lalala";
[userName setFont:[UIFont fontWithName:@"HelveticaNeue" size:20]];
[headerView addSubview:userName];
[headerView setBackgroundColor:[UIColor clearColor]];
[userName setBackgroundColor:[UIColor clearColor]];
return headerView;
}
但我的头靠近细胞:
为什么?
仅供参考,您可以用故事板拖出一个UIView并将其放置为表格标题。然后将其分配给IBOutlet。 – Gobot 2012-03-16 14:11:57