gpt4 book ai didi

ios - 如何更改 UINavigationBar 的字体和颜色?

转载 作者:行者123 更新时间:2023-11-28 11:14:30 24 4
gpt4 key购买 nike

我想从 AppDelegate 更改我的 UINavigationBar 的字体和颜色。为此,我这样做:

let appearance = UINavigationBar.appearance()
appearance.translucent = false
appearance.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Chalkduster", size: 21)!]
appearance.barTintColor = UIColor(red: 80/255, green: 185/255, blue: 225/255, alpha: 1)
appearance.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]

但在这种情况下仅适用于其中之一,例如:

如果我首先设置 - 字体,然后设置 - 颜色,它只会改变颜色,而不是字体。如果我首先设置 - 颜色,在第二个 - 字体,它只会改变字体,而不是颜色。

如何更改它们?

最佳答案

let appearance = UINavigationBar.appearance()
appearance.translucent = false
appearance.barTintColor = UIColor(red: 80/255, green: 185/255, blue: 225/255, alpha: 1)
appearance.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Chalkduster", size: 21)!, NSForegroundColorAttributeName: UIColor.whiteColor()]

关于ios - 如何更改 UINavigationBar 的字体和颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32720531/

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