Closed StackHelp closed 4 years ago
Have you tried
tabBarController.highlightedBackgroundColor = myColor
tabController.highlightButton(atIndex: 2)
@Minitour let me check
Does tabController.highlightButton(atIndex: 2)
needs to call on any delegate? Because this method fixed the color for the tab not changed to the initial color.
Fixed with this code. Any other solution you have?
func tabBar(_ tabBar: AZTabBarController, didSelectTabAtIndex index: Int) {
print("didSelectTabAtIndex \(index)")
for (i, _) in tabController.buttons.enumerated() {
if i == index {
tabController.highlightButton(atIndex: i)
} else {
tabController.removeHighlight(atIndex: i)
}
}
}
I’m not sure I understand your desired functionality. Do you want the background to change when you click a button? Or just have a fixed background for one button like you showed in the picture?
Yes, Want to change the background color on click of tab item.
Yeah I don’t remember implementing such functionality, your delegate workaround would do just fine.
I'm trying to change the background of a selected TabBarItem like below
how can we achieve this?