如上图,在第一个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";
}
(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 22;
}
(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.1;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。