【问题标题】:Change UITableView header tint color更改 UITableView 标题色调颜色
【发布时间】:2013-02-18 08:17:32
【问题描述】:

我已经实现了以下代码,以更改 tableView 中节标题的 tint。我只想更改颜色,而不是应用我自己的视图。但是,该应用程序似乎忽略了它,并且部分标题继续以默认灰色显示。关于我可能做错了什么的任何线索?非常感谢!

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    [[tableView headerViewForSection:section] setTintColor:[UIColor brownColor]];
    return [tableView headerViewForSection:section];
}

【问题讨论】:

  • 请用谷歌搜索...当然你会得到答案@Álvaro Morales Navarro
  • 看到这个stackoverflow.com/questions/813068/…@Álvaro Morales Navarro
  • 谢谢巴布尔,我确实用谷歌搜索了好几天。解决方案不使用 setTintColor 方法,所以这不是我要找的。无论如何感谢您的帮助。 :-)
  • 再次感谢!我终于在stackoverflow.com/questions/3294876/… 中找到了我想要的东西

标签: xcode uitableview header tint


【解决方案1】:

这是 100% 的工作,您可以更改索引或标题文本颜色

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    view.tintColor = [UIColor blueColor];

    // if you have index/header text in your tableview change your index text color 
    UITableViewHeaderFooterView *headerIndexText = (UITableViewHeaderFooterView *)view;
    [headerIndexText.textLabel setTextColor:[UIColor blackColor]];

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-23
    • 2011-03-18
    • 2011-01-24
    • 2012-09-10
    • 2013-01-03
    • 2019-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多