amirtmgr
amirtmgr

Reputation: 303

How to make UITabbar transparent so that background image of superview is visible?

I've used UITabbar. I've set it's background color to clear color. Even though the black colored background is appearing. I debugged the view and found that the UITabbar has implemented UIVisualEffectSubView and UIVisualEffectBackdropView to black color implicitly. What could be the better way to make it transparent with swift 4. Image of debug is attached below. enter image description here

Upvotes: 1

Views: 1605

Answers (2)

Taimoor Suleman
Taimoor Suleman

Reputation: 1616

Try this:

yourTabBar.backgroundColor = UIColor.clear // clears the background
yourTabBar.backgroundImage = UIImage()
yourTabBar.shadowImage = UIImage()  // removes the border

iOS 15 UPDATE

For Coloured background

if #available(iOS 15.0, *) {
    let appearance = UITabBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = .YourColor
    tabBar.standardAppearance = appearance
    tabBar.scrollEdgeAppearance = appearance
}

For Transparent Appearance

if #available(iOS 15.0, *) {
    let appearance = UITabBarAppearance()
    appearance.configureWithTransparentBackground()
    tabBar.standardAppearance = appearance
    tabBar.scrollEdgeAppearance = appearance
 }

Upvotes: 3

Kuldeep Tanwar
Kuldeep Tanwar

Reputation: 3526

You need to use the barTintColor on your tabBar

tabBar.backgroundColor = UIColor.clear
tabBar.barTintColor = UIColor.clear
tabBar.backgroundImage = UIImage()

Upvotes: 0

Related Questions