ios - 如何使 UITabbar 透明以便 superview 的背景图像可见?

标签 ios swift xcode uitabbar

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

最佳答案

试试这个:

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
 }

关于ios - 如何使 UITabbar 透明以便 superview 的背景图像可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50343502/

相关文章:

ios - Swift 语言中的 _cmd

json - 使用 jq 获取数组中 shell 定义的 JSON 对象内特定键的值

ios - MFMailComposeViewController 一直自动关闭

ios - 滚动 tableView 时复制数据

objective-c - UITableViewCell subview 的 NSIndexPath?

ios - iPhone 4 应用程序使用 sqlite 数据库

iphone - iOS:录音文件格式

ios - CoreData 不跨多个 iOS 设备存储数据

ios - SpriteKit 的坐标系在 Xcode 8 中是否发生了变化?

ios - 如何使用 RxSwift 强制点击 UIButton?