- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320, 20.0)];
UIImageView *bg = [[UIImageView alloc]initWithFrame:customView.frame];
bg.image = [UIImage imageNamed:@"carTypeCellTitleBg1.png"];
[customView addSubview:bg];
// create the button object
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor colorWithRed:242.0/255.0f green:161.0/255.0f blue:4.0/255.0 alpha:1.0];
// headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont italicSystemFontOfSize:15];
headerLabel.frame = customView.frame;
// If you want to align the header text as centered
// headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0);
// headerLabel.text = <Put here whatever you want to display> // i.e. array element
headerLabel.text = @"title";
[customView addSubview:headerLabel];
return customView;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 21.0;
}