I would like to change the weight of my Tab Bar Item and font when it is selected. I assume this can be done by changing the Tab Bar Item Image and text when the associated tab is being selected. Apart from adjusting the tintcolor of highlighted tab bar items, I can't seem to find any information customising selected Tab Bar Items online even though most apps (including Instagram) do it. How is this done?
My current 5 tab bars are created in a UITabBarController Class and follow an almost identical formula like this:
let homeController = HomeViewController()
homeController.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "home"), tag: 1)
let nav1 = UINavigationController(rootViewController: homeController)
viewControllers = [nav1, nav2, nav3, nav4, nav5]
Programmatically set selected UITabbarItem
's image:
let tabBarItem = UITabBarItem(title: "title", image: UIImage(named: "defaultImage"), selectedImage: UIImage(named: "selectedImage"))
You can't as easily set selected UITabbarItem
's font though. You'd need to create your own UITabBarController
as shown in this SO thread.