Reputation: 870
I have a subclass of UITabBarController
with 5 items.
The 5th item is the user avatar.
final class HomeSceneViewController: UITabBarController {
init(tabs: [UIViewController]) {
super.init(nibName: nil, bundle: nil)
viewControllers = tabs
configureUI()
}
required init?(coder: NSCoder) {
return nil
}
}
private extension HomeSceneViewController {
func configureUI() {
view.backgroundColor = .white
tabBar.unselectedItemTintColor = .red
tabBar.tintColor = .blue
}
}
Currently each view controller sets it's own tabBarItem
property using tabBarItem = UITabBarItem(title: nil, image: tab.iconOff, selectedImage: tab.iconOn)
which works, however the unselectedItemTintColor
is setting an overlay on the avatar which I do not want as it should show the avatar as is.
Is it possible to set unselectedItemTintColor
on a per tab basis?
Upvotes: 0
Views: 118
Reputation: 16381
Try providing the image with renderingMode(.alwaysOriginal) like this:
tabBarItem = UITabBarItem(title: nil,
image: tab.iconOff?.withRenderingMode(.alwaysOriginal),
selectedImage: tab.iconOn?.withRenderingMode(.alwaysOriginal))
Upvotes: 2