Skip to content

Instantly share code, notes, and snippets.

@ecpplus
Created December 2, 2011 18:54
Show Gist options
  • Save ecpplus/1424388 to your computer and use it in GitHub Desktop.
Save ecpplus/1424388 to your computer and use it in GitHub Desktop.
UITableView のヘッダのテキストを変更(任意のUIViewに変更可)
-(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *titleWrapper = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 120, 40)] autorelease];
UILabel *titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15, 15, 100, 20)] autorelease];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = [UIColor redColor];
titleLabel.font = [UIFont boldSystemFontOfSize:18];
switch(section) {
case 0:
titleLabel.text = @"アプリ設定";
break;
case 1:
titleLabel.text = @"プロフィール設定";
break;
case 2:
titleLabel.text = @"初期化";
break;
}
[titleWrapper addSubview:titleLabel];
return titleWrapper;
}
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 20;
}
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 44;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment