【问题标题】:Background-color of UITabBarItem?(Swift/xCode)UITabBarItem 的背景颜色?(Swift/xCode)
【发布时间】:2018-08-12 10:00:53
【问题描述】:

我尝试更改我的UITabBarItems 的背景颜色,以摆脱图标周围这些丑陋的绿色边框

当我在AppDelegate 中注释掉这一行时,问题就消失了:

UIView.appearance().backgroundColor = UIColor(red: 0.12, green: 0.67, blue: 0.478, alpha: 1)

我已经尝试了几件事,但是当我想要绿色的UIView 背景和带有白色图标和字体的浅黑色导航栏时,似乎没有机会这样做。

这是我的UITabBar 的设置。将半透明从 true 更改为 false 并没有解决问题..

【问题讨论】:

  • 我认为问题出在您的标签栏图像上。你能把那个推特图标添加到你的问题中吗?

标签: ios swift xcode uinavigationbar tabbar


【解决方案1】:

通过代码我试图改变它的工作原理。 试试这行代码(通过指定你自己的颜色):

self.tabBarController?.tabBar.tintColor    = UIColor.white

self.tabBarController?.tabBar.unselectedItemTintColor = UIColor.white

self.tabBarController?.tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.blue,size: tabBarItemSize).resizableImage(withCapInsets: .zero)

希望对你有帮助

【讨论】:

  • 嘿!感谢您的帮助,但我的失败在于 AppDelegate。我通过在每个 ViewController 上设置新的 backgroundColor 来解决这个问题。 :-)
猜你喜欢
  • 2018-01-01
  • 2018-06-17
  • 1970-01-01
  • 1970-01-01
  • 2015-10-09
  • 2013-03-04
  • 1970-01-01
  • 1970-01-01
  • 2014-07-29
相关资源
最近更新 更多