如上图,在第一个section它的头部比其他section大,只是为何?如何解决?
相关代码
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
if (sectionTitle == nil) {
return nil;
}
// Create label with section title
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake((SCREEN_WIDTH-200)/2, 10, 200, 25);
label.backgroundColor = [UIColor clearColor];
label.textColor = BarCOLOR;
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
label.textAlignment = NSTextAlignmentCenter;
label.text = sectionTitle;
// Create header view and add label as a subview
UIView *sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 22)];
[sectionView setBackgroundColor:[UIColor blackColor]];
[sectionView addSubview:label];
return sectionView;
return nil;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"12232211";
}