【问题标题】:How to change header view background color if I still want to use the standard headerview如果我仍想使用标准标题视图,如何更改标题视图背景颜色
【发布时间】:2014-02-26 19:48:26
【问题描述】:

一种方法是使用

tableView:viewForHeaderInSection:

但是,这意味着我必须提供自己的headerView

我想要普通的标准headerView

我只想更改background color

我该怎么做?

【问题讨论】:

    标签: objective-c uitableview background-color


    【解决方案1】:

    来自 UITableViewDelegate 协议的结帐方法:

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

    这里你得到了将要显示的标题视图(view)。

    可能是这样的:

    - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
    {
        [view setBackgroundColor:[UIColor redColor]];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 2012-07-12
      相关资源
      最近更新 更多