gpt4 book ai didi

ios - tabBarController navigationItem.title 颜色

转载 作者:搜寻专家 更新时间:2023-11-01 06:55:31 24 4
gpt4 key购买 nike

我设置的标题如下,但是我也想改变文本的颜色,但是没有textattributes,我想知道怎么办?

self.tabBarController?.navigationItem.title = "Settings"

我也尝试了以下方法,但它甚至没有显示标签。

let navLabel = UILabel()
let navTitle = NSMutableAttributedString(string: "Settings", attributes:[
NSAttributedString.Key.foregroundColor: UIColor.blue,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17.0, weight: UIFont.Weight.light)])

navLabel.attributedText = navTitle
self.tabBarController?.navigationItem.titleView = navTitle

最佳答案

试试这段代码,希望对你有帮助。

build设置\Swift 语言版本:4.1

一般\部署目标:10.3

let attrsNormal = [NSAttributedStringKey.foregroundColor : UIColor.black,
NSAttributedStringKey.font : UIFont(name: "Arial", size: 14)!]
UITabBarItem.appearance().setTitleTextAttributes(attrsNormal,
for: UIControlState.normal)

关于ios - tabBarController navigationItem.title 颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53699582/

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