在 Swift 中无法摆脱 TabBar 后面的灰色
Cant get rid of grey colour behind TabBar in Swift
我在我的视图中放了一张背景图片,所以完整视图应该有它。
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 透明了一定百分比时,我可以看到灰色(可能是默认颜色)后面而不是视图的背景图像...
调试视图层次结构:
尝试以下方法
UITabBar.appearance().isTranslucent = false
我在我的视图中放了一张背景图片,所以完整视图应该有它。
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 透明了一定百分比时,我可以看到灰色(可能是默认颜色)后面而不是视图的背景图像...
调试视图层次结构:
尝试以下方法
UITabBar.appearance().isTranslucent = false