在我更新到 IOS 13 之前,我有一个可以正确显示的应用。
在旧版本的应用程序(iOS 13 之前)中,标题文本颜色显示正确。见下文。
现在标题显示如下:
我没有改变任何东西,所以我假设苹果方面发生了一些变化。 这就是我设置标题文本颜色的方式:
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let header = view as! UITableViewHeaderFooterView
header.textLabel?.textColor = Styles.greyColor()
header.backgroundView?.backgroundColor = Styles.mainColor()
header.textLabel?.font = UIFont.systemFont(ofSize: 13, weight: UIFont.Weight.light)
}
它要求的颜色是这样创建的:
static func greyColor() -> UIColor{
return uicolorFromHex(0x9B9B9B)
}
static func mainColor() -> UIColor {
// blue background
//return uicolorFromHex(0x222C45)
return uicolorFromHex(0x1B2337)
}
这可能已经被讨论过,但我似乎找不到任何关于它的最新帖子。
最佳答案
我能够通过添加来解决这个问题:
header.contentView.backgroundColor = Styles.mainColor()
希望这对处于相同情况的任何人都有帮助。
关于ios - 如何为 UITableView 标题设置颜色文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58054801/