【发布时间】:2010-10-23 05:17:35
【问题描述】:
如何在 UITableView 中更改节标题的颜色?
编辑:answer provided by DJ-S 应考虑用于 iOS 6 及更高版本。接受的答案已过期。
【问题讨论】:
-
我非常感谢编辑 RE 较新的 iOS 版本。
标签: ios uitableview cocoa-touch
如何在 UITableView 中更改节标题的颜色?
编辑:answer provided by DJ-S 应考虑用于 iOS 6 及更高版本。接受的答案已过期。
【问题讨论】:
标签: ios uitableview cocoa-touch
使用 RubyMotion / RedPotion,将其粘贴到您的 TableScreen 中:
def tableView(_, willDisplayHeaderView: view, forSection: section)
view.textLabel.textColor = rmq.color.your_text_color
view.contentView.backgroundColor = rmq.color.your_background_color
end
像魅力一样工作!
【讨论】:
虽然func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) 也可以工作,但您可以在不实现其他委托方法的情况下实现这一目标。
在你的 func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? 方法中,你可以使用 view.contentView.backgroundColor = UIColor.white 而不是 view.backgroundView?.backgroundColor = UIColor.white 这不起作用。 (我知道backgroundView 是可选的,但即使它在那里,如果不实现willDisplayHeaderView 也不会工作
【讨论】:
使用 UIAppearance,您可以为应用程序中的所有标题更改它,如下所示:
UITableViewHeaderFooterView.appearance().backgroundColor = theme.subViewBackgroundColor
【讨论】:
iOS 13> 斯威夫特 5
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {view.tintColor = UIColor.red }
【讨论】: