Skip to content

Instantly share code, notes, and snippets.

@grgcombs
Created September 29, 2011 14:24
Show Gist options
  • Save grgcombs/1250824 to your computer and use it in GitHub Desktop.
Save grgcombs/1250824 to your computer and use it in GitHub Desktop.
RKTableViewSections from @jeffarena
// This would be inserted somewhere in your app-wide tableviewcontroller superclass configuration, to reap the benefits across all subsequent tables.
self.tableController.heightForHeaderInSection = 22;
self.tableController.onViewForHeaderInSection = ^UIView*(NSUInteger sectionIndex, NSString* sectionTitle) {
UIView* headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 22)] autorelease];
headerView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"sectionheader_bg.png"]];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, self.tableView.bounds.size.width, 22)];
label.text = sectionTitle;
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:12];
[headerView addSubview:label];
[label release];
return headerView;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment