我已经尝试设置UITabBar
的色调颜色和背景颜色已有相当长的一段时间了,似乎没有任何效果。到目前为止,我已经尝试过:
tabBarController?.tabBar.backgroundColor = UIColor.orangeColor()
tabBarController?.tabBar.barTintColor = UIColor.whiteColor()
以及:
UITabBar.appearance().tintColor = UIColor.orangeColor()
这些似乎都不会对我的标签栏产生任何影响。我还要提及的是,我将VC嵌入在导航控制器中,为此,我设置的全局色调很好用。
如果要隐式设置标签栏的tint and barTint color
,则在Appdelegate.swift
中,
UITabBar.appearance().barTintColor = .orange
UITabBar.appearance().tintColor = .green
如果要为特定的viewController设置标签栏的tint and barTint color
,则在ViewController.swift
中,
self.tabBarController?.tabBar.tintColor = .orange
self.tabBarController?.tabBar.barTintColor = .green
Swift 4+版本
UITabBar.appearance().barTintColor = UIColor.red
UITabBar.appearance().tintColor = UIColor.white