为什么UIBarButtonItem文本颜色alpha为0?

时间:2018-08-10 08:10:10

标签: ios uibarbuttonitem uitoolbar

我使用UIToolbar和UIBarButtonItem作为标题创建自定义视图。

这是我想要的

enter image description here

这实际上是显示的内容:

enter image description here

标题不见了。我发现UIButtonLabel文本颜色的alpha值为0:

enter image description here

有人对这种情况为什么发生以及如何解决有任何想法。谢谢!

1 个答案:

答案 0 :(得分:0)

我认为您应该给导航栏指定title属性。如果您使用了任何自定义导航栏,那么我将在默认导航栏的title属性下设置,然后在以下代码中设置该导航栏。

self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor:UIColor.black]
相关问题