Posted By

saturngod on 03/23/11


Tagged


Versions (?)

TableHeader Font


 / Published in: Objective C
 

  1. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  2. {
  3. // create the parent view that will hold header Label
  4. UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)];
  5. NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
  6. // create the button object
  7. UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  8. headerLabel.backgroundColor = [UIColor clearColor];
  9. headerLabel.opaque = NO;
  10. headerLabel.textColor = [UIColor blackColor];
  11. headerLabel.highlightedTextColor = [UIColor whiteColor];
  12. headerLabel.font = [UIFont boldSystemFontOfSize:20];
  13. headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 44.0);
  14.  
  15. // If you want to align the header text as centered
  16. // headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0);
  17.  
  18. headerLabel.text = sectionTitle; // i.e. array element
  19. [customView addSubview:headerLabel];
  20.  
  21. return customView;
  22. }

Report this snippet  

You need to login to post a comment.