I am making a UITabBarController programmatically with a couple of tabs, however for some motive I can’t get the traditional state of the tabs icons or textual content to alter shade. Its defaulting to a system white. I can solely modify the chosen state.
I’ve tried creating the tabs in a number of methods, however all appear to return the identical outcome. The one factor I’ve managed to work round is by forcing the icons (that are templates) to render as originals after tinting them. This solely works for the icons, leaving the textual content within the system white shade, so i’ve disabled it because it seems to be worse to have one in every of every
personal func configureTabs() {
let inbox = InboxViewController()
inbox.tabBarItem = UITabBarItem(
title: "INBOX",
//picture: UIImage(named: "tab-inbox")?.withTintColor(AppColors.t3, renderingMode: .alwaysOriginal),
//selectedImage: UIImage(named: "tab-inbox")?.withTintColor(AppColors.t1, renderingMode: .alwaysOriginal)
picture: UIImage(named: "tab-inbox"),
selectedImage: UIImage(named: "tab-inbox")
)
let seize = CaptureViewController()
seize.tabBarItem = UITabBarItem(
title: "CAPTURE",
//picture: UIImage(named: "tab-inbox")?.withTintColor(AppColors.t3, renderingMode: .alwaysOriginal),
//selectedImage: UIImage(named: "tab-inbox")?.withTintColor(AppColors.t1, renderingMode: .alwaysOriginal)
picture: UIImage(named: "tab-capture"),
selectedImage: UIImage(named: "tab-capture")
)
tabBar.tintColor = AppColors.t1
tabBar.unselectedItemTintColor = AppColors.t3
viewControllers = [
inbox,
capture
]
}
I’ve additionally tried setting the Look proxy in 2 other ways, with many variations of settings in every:
personal func configureAppearance() {
// NavBar
let navAppearance = UINavigationBarAppearance()
navAppearance.configureWithDefaultBackground()
navAppearance.backgroundColor = AppColors.bg
navAppearance.shadowColor = AppColors.border
navigationController?.navigationBar.standardAppearance = navAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navAppearance
navigationController?.navigationBar.tintColor = AppColors.t1
// TabBar
let normalColor = AppColors.t3
let selectedColor = AppColors.t1
let normalFont = UIFont(title: UIFont.JetBrainsMono.common, dimension: 10) as Any
let selectedFont = UIFont(title: UIFont.JetBrainsMono.regular_semiBold, dimension: 10) as Any
let normalTitleAttributes: [NSAttributedString.Key: Any] = [
.font: normalFont,
.foregroundColor: normalColor
]
let selectedTitleAttributes: [NSAttributedString.Key: Any] = [
.font: selectedFont,
.foregroundColor: selectedColor
]
let look = UITabBarAppearance()
//look.configureWithOpaqueBackground()
func configure(_ itemAppearance: UITabBarItemAppearance) {
itemAppearance.regular.iconColor = normalColor
itemAppearance.regular.titleTextAttributes = normalTitleAttributes
itemAppearance.chosen.iconColor = selectedColor
itemAppearance.chosen.titleTextAttributes = selectedTitleAttributes
}
configure(look.stackedLayoutAppearance)
configure(look.inlineLayoutAppearance)
configure(look.compactInlineLayoutAppearance)
tabBar.standardAppearance = look
tabBar.scrollEdgeAppearance = look
tabBar.tintColor = selectedColor
tabBar.unselectedItemTintColor = normalColor
}
and with a constraint:
func setupAppearence() {
let look = UITabBarItem.look(whenContainedInInstancesOf: [MainTabBarController.self])
look.setTitleTextAttributes([
NSAttributedString.Key.foregroundColor: AppColors.t3,
//NSAttributedString.Key.font: UIFont.custom(ofType: .medium, andSize: 10)
], for: .regular)
look.setTitleTextAttributes([
NSAttributedString.Key.foregroundColor: AppColors.t1,
//NSAttributedString.Key.font: UIFont.custom(ofType: .medium, andSize: 10)
], for: .chosen)
self.tabBar.shadowImage = nil
self.tabBar.tintColor = AppColors.t1
self.tabBar.unselectedItemTintColor = AppColors.t3
}
I can get the font household, dimension and weight to alter, however not the colour. I believed possibly my AppColors.t1 might need been incorrectly set someplace, so I tweaked that worth and solely the chosen state modified. So its not utilizing my whiteish .t1 shade as the traditional state, its choosing up a system shade from someplace, however I cant work out the place.
Have I missed a property someplace? is there a liquid glass mode I’ve to toggle on to permit totally different colours or one thing? What have I missed? AI has been no assist
