首页 > 解决方案 > 设置 UITabBarItem 属性文本不起作用

问题描述

我想更改标签栏的文本样式、字体和颜色。我已经尝试过外观代理方法AppDelegate但它不起作用,然后我尝试单独调用setTitleTextAttributes()每个UITabBarItem,它也不起作用。我很沮丧(iOS 13)!

let appearance = UITabBarItem.appearance()

appearance.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)

appearance.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.green], for: .selected)

以上不起作用

唯一能改变默认颜色的方法是通过UITabBar外观代理设置色调颜色AppDelegate

UITabBar.appearance().tintColor = UIColor.black

我不能用这个改变字体。iOS13有变化吗?我在 Appel 文档中找不到任何关于它的信息。

标签: swift

解决方案


推荐阅读