【发布时间】:2018-05-15 06:20:33
【问题描述】:
我用过 UITabbar。我已经将它的背景颜色设置为清除颜色。即使出现黑色背景。我调试了视图,发现 UITabbar 已经将 UIVisualEffectSubView 和 UIVisualEffectBackdropView 实现为黑色。使用 swift 4 使其透明的更好方法可能是什么。调试图像附在下面。
【问题讨论】:
-
你试过
tintColor?
我用过 UITabbar。我已经将它的背景颜色设置为清除颜色。即使出现黑色背景。我调试了视图,发现 UITabbar 已经将 UIVisualEffectSubView 和 UIVisualEffectBackdropView 实现为黑色。使用 swift 4 使其透明的更好方法可能是什么。调试图像附在下面。
【问题讨论】:
tintColor?
试试这个:
yourTabBar.backgroundColor = UIColor.clear // clears the background
yourTabBar.backgroundImage = UIImage()
yourTabBar.shadowImage = UIImage() // removes the border
iOS 15 更新
彩色背景
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .YourColor
tabBar.standardAppearance = appearance
tabBar.scrollEdgeAppearance = appearance
}
为了透明的外观
if #available(iOS 15.0, *) {
let appearance = UITabBarAppearance()
appearance.configureWithTransparentBackground()
tabBar.standardAppearance = appearance
tabBar.scrollEdgeAppearance = appearance
}
【讨论】:
您需要在 tabBar 上使用 barTintColor
tabBar.backgroundColor = UIColor.clear
tabBar.barTintColor = UIColor.clear
tabBar.backgroundImage = UIImage()
【讨论】: