我正在尝试为 UITableView 自定义节标题。UITableView 是在 IB 中创建的。我有两个我无法弄清楚的问题。
无论 UILabel 有多大,字体大小都不会超过 18 左右。
部分标题遮盖了表格。
我把标签涂成蓝色,这样你就可以看到它们的大小。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// Name of section
NSString *header = [[purchases allKeys] objectAtIndex:section];
// Label for section header
UILabel *label = [[[UILabel alloc] init] autorelease];
label.frame = CGRectMake(10, 0, 230, 45);
label.textColor = _orange;
label.font = [UIFont fontWithName:@"Heiti TC Medium" size:52];
label.text = header;
label.backgroundColor = [UIColor blueColor];
// View to contain label
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 230, 45)];
[view autorelease];
[view addSubview:label];
return view;
}