【问题标题】:How to make UITabbar transparent so that background image of superview is visible?如何使 UITabbar 透明以便超级视图的背景图像可见?
【发布时间】:2018-05-15 06:20:33
【问题描述】:

我用过 UITabbar。我已经将它的背景颜色设置为清除颜色。即使出现黑色背景。我调试了视图,发现 UITabbar 已经将 UIVisualEffectSubViewUIVisualEffectBackdropView 实现为黑色。使用 swift 4 使其透明的更好方法可能是什么。调试图像附在下面。

【问题讨论】:

  • 你试过tintColor

标签: ios swift xcode uitabbar


【解决方案1】:

试试这个:

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
 }

【讨论】:

    【解决方案2】:

    您需要在 tabBar 上使用 barTintColor

    tabBar.backgroundColor = UIColor.clear
    tabBar.barTintColor = UIColor.clear
    tabBar.backgroundImage = UIImage()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 2013-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多