【发布时间】:2016-11-16 04:33:12
【问题描述】:
我正在尝试将标签栏设置为在每个视图控制器上具有不同的背景图像。
class CharacterVC: UIViewController {
var tabBarApparence = UITabBar.appearance()
override func viewDidLoad() {
super.viewDidLoad()
tabBarApparence.backgroundImage = UIImage(named: "BlueTB") //Loaded from Image Asset
}
这工作正常并在该视图中将其更改为蓝色,但是当我转到下一个视图时,它保持蓝色并且不会更改为我使用此代码编程的红色:
class AnonVC: UIViewController {
var tabBarApparence = UITabBar.appearance()
override func viewDidLoad() {
super.viewDidLoad()
tabBarApparence.backgroundImage = UIImage(named: "RedTabBar")
// addtional code here
}
我有另外 2 个视图控制器,一个应该显示图像的绿色版本,另一个显示图像的紫色版本。
有什么建议可以解决这个问题吗?
【问题讨论】: