【问题标题】:Set background color on UITableView in IOS 6 [duplicate]在IOS 6中的UITableView上设置背景颜色[重复]
【发布时间】:2012-09-19 00:49:24
【问题描述】:

可能重复:
Change background of a grouped UITableView

如果 UITableView 是UITableViewStyleGrouped,我无法更改它的背景颜色。 我的代码:

[addressNewTbl setBackgroundColor:[UIColor redColor]];

救命!

【问题讨论】:

  • 欢迎来到 Stack。如果你得到了答案,那么你应该接受那个答案......

标签: iphone ipad uitableview ios6


【解决方案1】:

您可能需要添加一些代码。 试试 -

[UITableView setBackgroundView: nil];

或者你也可以这样做:

UIView* bview = [[UIView alloc] init];
bview.backgroundColor = [UIColor yellowColor];
[tableView setBackgroundView:bview];

两者都可以..

【讨论】:

  • 是的。第二个也适用于向后兼容
  • 当你对 UITableView 进行分组时,会设置 backgroundView,使用 self.tableView.backgroundView = nil;你删除它
【解决方案2】:

你试过了吗

addressNewTbl.backgroundView = nil;
[addressNewTbl setBackgroundColor:[UIColor redColor]];

【讨论】:

    【解决方案3】:

    您还需要禁用背景视图:

    [addressNewTbl setBackgroundView:nil];
    

    【讨论】:

      【解决方案4】:

      不要设置整个UITableView 的背景颜色,而是尝试设置backgroundView 的背景颜色时会发生什么。

      【讨论】:

        【解决方案5】:

        在 cellForRowAtIndexPath 数据源方法中尝试设置

        [cell setBackgroundColor:[UIcolor redColor]];
        

        【讨论】:

        • OP 是关于表格的背景而不是单元格的背景..
        猜你喜欢
        • 2014-09-04
        • 1970-01-01
        • 2015-11-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多