Search code examples
swiftviewuitabbarcontrolleruicolortabbar

Cant get rid of grey colour behind TabBar in Swift


I put a background image to my view, so the full view should have it.

let background = UIImage(named: "background")
var imageView : UIImageView!
imageView = UIImageView(frame: view.bounds)
imageView.contentMode =  UIView.ContentMode.scaleAspectFill
imageView.clipsToBounds = true
imageView.image = background
imageView.center = view.center
view.addSubview(imageView)
self.view.sendSubviewToBack(imageView)

Also I have a barTintColor for my tabBar:

tabBar.barTintColor = UIColor.blue

The problem is when my TabBar is transparent for some percent, I can see behind the grey color(probably the default color) instead of my view's background image...


Debug view hierarchy:

enter image description here


Solution

  • Try the following

    UITabBar.appearance().isTranslucent = false