Skip to content

Instantly share code, notes, and snippets.

@vincent178
Created August 31, 2013 02:56
Show Gist options
  • Save vincent178/6395972 to your computer and use it in GitHub Desktop.
Save vincent178/6395972 to your computer and use it in GitHub Desktop.
UITableViewCell Header Customize
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *result = nil;
if ([tableView isEqual:self.myTableView] && section == 0) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.text = @"Section 1 Header";
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
label.frame = CGRectMake(label.frame.origin.x + 10.0f, 5.0f, label.frame.size.width, label.frame.size.height);
CGRect resultFrame = CGRectMake(0.0f, 0.0f, label.frame.size.width, label.frame.size.height);
result = [[UIView alloc] initWithFrame:resultFrame];
[result addSubview:label];
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment