TabBar的背景颜色在选项卡选择上发生变化

时间:2016-06-22 05:59:02

标签: ios swift uitabbaritem

我不知道为什么会这样,我在我的故事板上查了一下,对于我的代码,我搜索了类似的问题,但没有找到任何东西。

在我的tabBar中我有4个标签,当我选择标签#2 tabBars背景颜色变暗但当我选择任何其他标签时它工作正常。请参阅图片以便更好地理解。

选择了tab1 enter image description here

选择了tab2(并且背景颜色也会改变

enter image description here 选中tab3,现在背景颜色正常

enter image description here

1 个答案:

答案 0 :(得分:0)

我认为您在显示第二个标签时设置标签栏颜色。因此,删除第二个选项卡中的背景颜色。如果您仍然无法在查看标签时尝试重置颜色: -

override func viewWillAppear(animated: Bool) {
    self.tabBarController?.tabBar.backgroundColor = UIColor.clearColor()
}