Skip to content

Instantly share code, notes, and snippets.

@dchohfi
Created April 9, 2012 19:49
Show Gist options
  • Save dchohfi/2346111 to your computer and use it in GitHub Desktop.
Save dchohfi/2346111 to your computer and use it in GitHub Desktop.
tableView:viewForHeaderInSection: like the default header view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
float width = tableView.bounds.size.width;
int fontSize = 18;
int padding = 10;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, fontSize)];
view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
view.userInteractionEnabled = YES;
view.tag = section;
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PlainTableViewSectionHeader.png"]];
image.contentMode = UIViewContentModeScaleAspectFit;
[view image];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(padding, 2, width - padding, fontSize)];
label.text = @"Texto";
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor darkGrayColor];
label.shadowOffset = CGSizeMake(0,1);
label.font = [UIFont boldSystemFontOfSize:fontSize];
[view addSubview:label];
return view;
}
@klimchuk
Copy link

klimchuk commented Jan 2, 2014

What [view image] means?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment