0
我想改變字體顏色在我的頭,所以,我委派viewForHeaderInSection:顏色更改爲標題中的UITableView
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
[headerLabel setBackgroundColor:[UIColor whiteColor]];
[headerLabel setTextColor:[UIColor blackColor]];
[headerView addSubview:headerLabel];
return headerView;
}
的背景顏色設置,但文本喜歡透明, 什麼也沒有。
我試着評論backgroundColor白色消失,但文字沒有。
我試着評論所有的塊,文本以默認的顏色出現。
我的錯誤在哪裏?謝謝你在前進
我找到了,我錯過了:
[headerLabel setText: @"myText"];
看來:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section
不叫執行viewForHeaderInSection時。
謝謝!
謝謝,我需要的字體顏色,但我已經得到它!我編輯了我的帖子。謝謝! – user1256477
我在你的代碼上面測試了你的代碼 –