0

i want to change the titleForHeader background color in iOS.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
     return @"A";
}

this method show the titleHeader section in UITableView.

for default it's background color is lightblue color.

I wan to change black color of these background.

How can i do?

Fire Fist
  • 7,032
  • 12
  • 63
  • 109

1 Answers1

1

Look at Alex Reynolds answer on here

UITableView - change section header color

    - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
    {
      UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)] autorelease];
      if (section == integerRepresentingYourSectionOfInterest)
         [headerView setBackgroundColor:[UIColor redColor]];
      else 
         [headerView setBackgroundColor:[UIColor clearColor]];


 return headerView;
}

If you just get a background color but no text

Look DoctorG answer on same question

       UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width - 10, 18)] autorelease];
    label.text = @"Section Header Text Here";
    label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.75];

label.backgroundColor = [UIColor clearColor];
[headerView addSubview:label];
Community
  • 1
  • 1
SpaceDust__
  • 4,844
  • 4
  • 43
  • 82
  • integerRepresentingYourSectionOfInterest is what bro? where i need to declare? – Fire Fist Jan 31 '13 at 17:13
  • 1
    how many sections do you have? it means an integer for example for your first section use 0 `if (section == 0)` second section `if (section == 1)` and so on – SpaceDust__ Jan 31 '13 at 17:16