如何在iOS中更改标题的背景色?

如何在iOS中更改标题的背景色?,ios,cocoa-touch,uitableview,Ios,Cocoa Touch,Uitableview,我想更改iOS中标题标题的背景色 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return @"A"; } 此方法在UITableView中显示标题标题部分 默认情况下,其背景色为浅蓝色 我想改变这些背景的黑色 我该怎么办?看看亚历克斯·雷诺兹的回答 如果你只是得到一个背景颜色,但没有文字 看一看同一个问题的答案 UILabe

我想更改iOS中标题标题的背景色

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
     return @"A";
}
此方法在
UITableView
中显示标题标题部分

默认情况下,其背景色为浅蓝色

我想改变这些背景的黑色


我该怎么办?

看看亚历克斯·雷诺兹的回答

如果你只是得到一个背景颜色,但没有文字

看一看同一个问题的答案

       UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width - 10, 18)] autorelease];
    label.text = @"Section Header Text Here";
    label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.75];

label.backgroundColor = [UIColor clearColor];
[headerView addSubview:label];

你感兴趣的部分是什么兄弟?我需要在哪里申报?你们有多少部分?它意味着一个整数,例如,对于您的第一部分,使用0
if(section==0)
second section
if(section==1)
等等
       UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(10, 3, tableView.bounds.size.width - 10, 18)] autorelease];
    label.text = @"Section Header Text Here";
    label.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.75];

label.backgroundColor = [UIColor clearColor];
[headerView addSubview:label];