无法摆脱Swift中TabBar后面的灰色

问题描述

我在背景视图中放置了背景图像,因此完整视图应该具有背景图像。

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)

我的tabBar也有barTintColor:

tabBar.barTintColor = UIColor.blue

问题是,当我的TabBar透明了一定百分比时,我可以看到灰色(可能是认颜色)的后面,而不是视图的背景图像...


调试视图层次结构:

enter image description here

解决方法

尝试以下

UITabBar.appearance().isTranslucent = false