958 characters | 22 lines | 958 Bytes
DOWNLOAD | RAW | EMBED | CREATE NEW VERSION OF THIS PASTE | REPORT ABUSE | x
  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. }