SwiftUI透明TabView(无背景模糊)?

发布于 2025-01-15 13:08:59 字数 398 浏览 5 评论 0原文

根据我在互联网上找到的信息,这个版本的 Swift 中的 Tabview 应该是透明的。

但就我而言,当它显示的视图中下方有东西时,它总是显示灰色调,顶部有一条线。如果我向下滚动到该视图中的空白空间,选项卡视图将再次变为透明。

多年来我一直在努力寻找解决方案,但我绝对是个菜鸟。有人可以帮我解决这个问题并使其始终透明吗?非常感谢!

截图:

下面有东西时呈灰色

当下面没有任何东西时透明

From what I found on the internet, the Tabview in this version of Swift is meant to be transparent.

But in my case it always dispalys a grayish tone with a line on top when there is something underneath it in the view it is displaying. If I scroll down to a space in that view which is empty, the tabview becomes transparent again.

I have been trying to find a solution to this for ages but I'm a absolute noob. Can someone please help me fix this and make it always transparent? Thank you so much!

Screenshots:

Grayish when there's something underneath

Transparent when there's nothing underneath

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一念一轮回 2025-01-22 13:08:59

使用 UIBarAppearance.configureWithTransparentBackground()

struct ContentView: View {

init() {
let transparentAppearence = UITabBarAppearance()
transparentAppearence.configureWithTransparentBackground() //

Use UIBarAppearance.configureWithTransparentBackground().

struct ContentView: View {
    
    init() {
        let transparentAppearence = UITabBarAppearance()
        transparentAppearence.configureWithTransparentBackground() // ????   
        UITabBar.appearance().standardAppearance = transparentAppearence
    }
    
    var body: some View {
        TabView {
            List {
                ForEach(1...40, id: \.self) { eachRowIndex in
                    Text("Row \(eachRowIndex)")
                }
            }
            .listStyle(.plain)
            .tabItem {
                Image(systemName: "house.fill")
                Text("Home")
            }
        }
    }
}

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文