viewForHeaderInSection
メソッドを使用します。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UILabel *label1 = [[UILabel alloc] init];
label1.frame = CGRectMake(0, 0, 190, 20);
label1.textColor = [UIColor blackColor];
// label1.font = [UIFont fontWithName:@"Helvetica Bold" size:16];
[label1 setFont:[UIFont fontWithName:@"Arial-BoldMT" size:14]];
label1.textAlignment = UITextAlignmentCenter;
label1.text =[NSString stringWithFormat:@"Title %d",section];
// If your title are inside an Array then Use Below Code
label1.text =[titleArray objectAtindex:section];
label1.textColor = [UIColor whiteColor];
label1.backgroundColor = [UIColor clearColor];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
[view addSubview:label1];
view.backgroundColor = [UIColor orangeColor];
return view;
}
使用したい場合titleForHeaderInSection
は、以下のコードを使用してください。
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [NSString stringWithFormat:@"Title %d",section];
// If your title are inside an Array then Use Below Code
return [titleArray objectAtindex:section];
}