Reputation:
I was able to set my tabBar to transparent with the code below but I don't know how to bring it back to default style. Please help if you can and thank you very much!
tabBarController?.tabBar.backgroundColor = .clear
tabBarController?.tabBar.backgroundImage = UIImage()
tabBarController?.tabBar.shadowImage = UIImage()
Upvotes: 0
Views: 131
Reputation: 20369
Before setting your tab bar to clear color save all the properties
let originalBackgroundImage = tabBarController?.tabBar.backgroundImage
let originalshadowImage = tabBarController?.tabBar.shadowImage
let originalbackgroundColor = tabBarController?.tabBar.backgroundColor
then change to clear color
tabBarController?.tabBar.backgroundColor = .clear
tabBarController?.tabBar.backgroundImage = UIImage()
tabBarController?.tabBar.shadowImage = UIImage()
Finally when you need it back
tabBarController?.tabBar.backgroundColor = originalbackgroundColor
tabBarController?.tabBar.backgroundImage = originalBackgroundImage
tabBarController?.tabBar.shadowImage = originalshadowImage
Finally call layoutIfNeeded
on tabBar
Hope it helps
Upvotes: 1