gpt4 book ai didi

ios - 如何为 UITableView 标题设置颜色文本颜色

转载 作者:行者123 更新时间:2023-11-28 05:37:48 25 4
gpt4 key购买 nike

在我更新到 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com