我使用此代码来清除选项卡栏:
self.tabBarController?.tabBar.backgroundImage = UIImage()
self.tabBarController?.tabBar.shadowImage = UIImage()
但在iOS 13中,我的代码不起作用。我试图使用以下代码:
if #available(iOS 13, *) {
let appearance = self.tabBarController?.tabBar.standardAppearance.copy()
appearance!.backgroundImage = UIImage()
appearance!.shadowImage = UIImage()
appearance!.shadowColor = .clear
self.tabBarController?.tabBar.standardAppearance = appearance!
} else {
self.tabBarController?.tabBar.backgroundImage = UIImage()
self.tabBarController?.tabBar.shadowImage = UIImage()
}
但在这种情况下,我的标签栏有白色,不清楚。
最佳答案
对于透明选项卡栏使用-configureWithTransparentBackground()
对于默认选项卡栏使用-configureWithDefaultBackground()
代码:
if #available(iOS 13, *) {
let appearance = self.tabBarController?.tabBar.standardAppearance.copy()
appearance!.configureWithTransparentBackground()
tabBarController?.tabBar.standardAppearance = appearance!
} else {
tabBarController?.tabBar.shadowImage = UIImage()
tabBarController?.tabBar.backgroundImage = UIImage()
}
关于ios - 如何在iOS 13中使标签栏清晰可见?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58174290/