Skip to content

Instantly share code, notes, and snippets.

@chrishulbert
Created May 6, 2011 03:58
Show Gist options
  • Save chrishulbert/958426 to your computer and use it in GitHub Desktop.
Save chrishulbert/958426 to your computer and use it in GitHub Desktop.
Centered header on a uitableview
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UILabel *lbl = [[[UILabel alloc] init] autorelease];
lbl.textAlignment = UITextAlignmentCenter;
lbl.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
lbl.text = @"My Centered Header";
lbl.textColor = [UIColor whiteColor];
lbl.shadowColor = [UIColor grayColor];
lbl.shadowOffset = CGSizeMake(0,1);
lbl.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"my_head_bg"]];
lbl.alpha = 0.9;
return lbl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment