导入UIKit
MainVC类:UITabBarController,UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
self.view.backgroundColor = .yellow
tabBar.tintColor = UIColor.init(displayP3Red: 0, green: 0, blue: 220, alpha: 1)
setuptabbar()
}
func setuptabbar() {
let hometab = UINavigationController(rootViewController: homeVC())
hometab.tabBarItem.image = UIImage(named: "home-off")
hometab.tabBarItem.selectedImage = UIImage(named: "home-on")
hometab.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: 0);
hometab.title = "save"
let RightTab = UINavigationController(rootViewController: page1())
RightTab.tabBarItem.image = UIImage(named: "his-off1")
RightTab.tabBarItem.selectedImage = UIImage(named: "his-on1")
RightTab.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: 0);
RightTab.title = "home"
let LeftTab = UINavigationController(rootViewController: page2())
LeftTab.tabBarItem.image = UIImage(named: "support")
LeftTab.tabBarItem.selectedImage = UIImage(named: "addmember")
LeftTab.title = "search"
let RightTab2 = UINavigationController(rootViewController: page4())
RightTab2.tabBarItem.image = UIImage(named: "share")
RightTab2.tabBarItem.selectedImage = UIImage(named: "support")
RightTab2.title = "profile"
let LeftTab2 = UINavigationController(rootViewController: page5())
LeftTab2.tabBarItem.image = UIImage(named: "title_icon")
LeftTab2.tabBarItem.selectedImage = UIImage(named: "addmember")
viewControllers = [RightTab , LeftTab, hometab , RightTab2 , LeftTab2 ]
guard let items = tabBar.items else {return}
for item in items{
item.imageInsets = UIEdgeInsets(top: 0, left: 0, bottom:0, right: 0)
}
}
}
答案 0 :(得分:0)
如果您不想隐藏标题,也可以通过设置相同的颜色来实现。
这是将要使用的一些代码
self.navigationItem.title = @"my title";
设置导航栏标题。
self.tabBarItem.title = @"my title";
设置标签栏标题。
self.title = @"my title";
设置这两个。 我希望它对您有用...:)