Here are two functions implementation but it does not display as desired
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 1)
{
CGRect rect = CGRectMake(10.0f,40.0f,300.0f,250.0f);
UILabel* label = [[[UILabel alloc] initWithFrame:rect] autorelease];
label.backgroundColor = [UIColor clearColor];
label.text = NSLocalizedString(@"MessageHeader","");;
label.baselineAdjustment= UIBaselineAdjustmentAlignCenters;
label.lineBreakMode = UILineBreakModeWordWrap;
label.textAlignment = UITextAlignmentCenter;
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake(0.0, 1.0);
label.font = [UIFont systemFontOfSize:14];
label.textColor = [UIColor darkGrayColor];
label.numberOfLines = 0;
UIView *view = [[[UIView alloc] initWithFrame:rect] autorelease];
[view addSubview:label];
return view;
}
}
return nil;
}
(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (section == 1)
{
CGRect rect = CGRectMake(10.0f,80.0f,300.0f,250.0f);
UILabel* label = [[[UILabel alloc] initWithFrame:rect] autorelease];
label.backgroundColor = [UIColor clearColor];
label.text = NSLocalizedString(@"MessageFooter","");
label.baselineAdjustment= UIBaselineAdjustmentAlignCenters;
label.lineBreakMode = UILineBreakModeWordWrap;
label.textAlignment = UITextAlignmentCenter;
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake(0.0, 1.0);
label.font = [UIFont systemFontOfSize:14];
label.textColor = [UIColor darkGrayColor];
label.numberOfLines = 0;
UIView *view = [[[UIView alloc] initWithFrame:rect] autorelease];
[view addSubview:label];
return view;
}
}
return nil;
}
What's wrong here? Why Header & footer text goes all the way to bottom of all the sections.