iPhone上默认的TableView部分标题背景颜色是什么?

Igo*_*gor 13 uitableview tableview

我想自定义TableView节标题并保留默认背景颜色.我用 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)部分.我需要根据设备(iPad或iPhone)更改字体大小.为此,请调用next函数:

[UIColor colorWithHue:0.6饱和度:0.33亮度:0.69 alpha:0.6].

但我手动找到了这些值.

Ras*_*tin 29

ios7的默认tableview部分标题背景颜色是

Objective-C
[UIColor colorWithRed:247/255.0f green:247/255.0f blue:247/255.0f alpha:1.0f]

Swift
UIColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1)
Run Code Online (Sandbox Code Playgroud)

  • 我希望这个答案能够针对 iOS13 和黑暗模式进行更新。我们是否可以使用任何标准 UIColor 来代替那些硬编码值? (3认同)

Dar*_*hal 5

对于更改TableView标头节的背景颜色,只需一行内容即可添加TableView委托willDisplayHeaderView

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {

   UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
   **header.tintColor = [UIColor whiteColor];**

}
Run Code Online (Sandbox Code Playgroud)