從@墊,CLAASSEN
感謝GitHub上的回覆
代碼
- (void)viewDidLoad {
[[self tableView] registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"headerFooterReuseIdentifier"];
}
部首
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
headerFooterView.contentView.backgroundColor = kBackgroundColor;
return headerFooterView;
}
頁腳
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
headerFooterView.contentView.backgroundColor = kBackgroundColor;
return headerFooterView;
}