- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 45.0f;
//set height according to row or section , whatever you want to do!
}
섹션 레이블 텍스트가 설정됩니다.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *sectionHeaderView;
sectionHeaderView = [[UIView alloc] initWithFrame:
CGRectMake(0, 0, tableView.frame.size.width, 120.0)];
sectionHeaderView.backgroundColor = kColor(61, 201, 247);
UILabel *headerLabel = [[UILabel alloc] initWithFrame:
CGRectMake(sectionHeaderView.frame.origin.x,sectionHeaderView.frame.origin.y - 44, sectionHeaderView.frame.size.width, sectionHeaderView.frame.size.height)];
headerLabel.backgroundColor = [UIColor clearColor];
[headerLabel setTextColor:kColor(255, 255, 255)];
headerLabel.textAlignment = NSTextAlignmentCenter;
[headerLabel setFont:kFont(20)];
[sectionHeaderView addSubview:headerLabel];
switch (section) {
case 0:
headerLabel.text = @"Section 1";
return sectionHeaderView;
break;
case 1:
headerLabel.text = @"Section 2";
return sectionHeaderView;
break;
case 2:
headerLabel.text = @"Section 3";
return sectionHeaderView;
break;
default:
break;
}
return sectionHeaderView;
}