【问题标题】:How to make tabBar clear in iOS 13?如何在 iOS 13 中使 tabBar 清晰?
【发布时间】:2019-09-30 19:40:15
【问题描述】:

我用这段代码让tabBar清晰:

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()
}

但在这种情况下,我的 tabBar 有白色,不清楚。

【问题讨论】:

标签: ios swift


【解决方案1】:

对于透明的 tabBar 使用 - configureWithTransparentBackground()

默认 tabBar 使用 - 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()
}

【讨论】:

    猜你喜欢
    • 2023-04-06
    • 1970-01-01
    • 2020-01-24
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    相关资源
    最近更新 更多