viewForHeaderInSection 的 textLabel 的 textColor 始终为灰色。BackgroundColor 按预期更改。以下是创建 headerview 的代码。它确实进入“!headerView”条件。使用 iOS SDK 7.1
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
static NSString *headerIdentifier = @"InspectionQuestionHeader";
UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerIdentifier];
if (!headerView) {
headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:headerIdentifier];
headerView.contentView.backgroundColor = [UIColor grayColor];
// Why doesn't this work?
headerView.textLabel.textColor = [UIColor whiteColor];
}
InspectionQuestionSection *questionSection = _questionSections[section];
NSString *title = [NSString stringWithFormat:@"%@. %@", questionSection.sectionNumber, questionSection.sectionDescription];
headerView.textLabel.text = title;
return headerView;
}