与 ScrollView 结合使用的自定义选项卡视图的问题

问题描述

我的选项卡视图的外观很棒。事实上,一切看起来都很好。但是使用当前的代码。 ScrollView 在标签栏后面而不是上面结束。我猜这与它是一个 ZStack(它 - 意味着内容)有关。

我尝试在开关内的每个视图上添加填充(填充底部标签栏高度相同但不起作用)。

我得到的两个结果要么是滚动不够看所有内容,但标签栏看起来不错。

滚动效果很好,但标签栏在显示空白时在视觉上有一些重叠问题。 我只是不知道如何再移动代码以获得更好的结果。 :(

//Landing-page..

        vstack {
            ZStack(alignment: Alignment(horizontal: .center,vertical: .bottom)) {
            switch tabController.selectedindex {
                case 0:
                    HomeView()
                        .padding(.bottom,50)
                case 1:
                    Text("Test..")
                case 2:
                    Text("Test...")
                case 3:
                    Text("Test....")
                default:
                    vstack {
                        Text("Default View")
                    }
                }
                
                CustomTabView()
            }
        }
        .background(Color.gray.ig@R_404_6462@esSafeArea()).edgesIg@R_404_6462@ingSafeArea(.bottom)
// TabView..

        HStack {
            // tabControllers.icons.count = 4 tabs at the moment
            ForEach(0..<tabController.icons.count,id: \.self) { tab in
                Button(action: {
                    // animation when changing tab comes here eventually
                    tabController.selectedindex = tab
                },label: {
                        Spacer()
                        Image(systemName: tabController.icons[tab])
                            .frame(width: 50,height: 50)
                            .font(.system(
                                    size: 22,weight: tabController.selectedindex == tab ? .semibold : .regular,design: .default))
                            .foregroundColor(tabController.selectedindex == tab ? Color.themeAccent : Color.themeAccent.opacity(0.3))
                            .background(tabController.selectedindex == tab ? Color.primaryPurple : nil)
                            .cornerRadius(tabController.selectedindex == tab ? 30 : 0)
                        Spacer()
                })
            }
        }
        .padding()
        .background(Color.blue)
        .clipShape(CShape())
        .shadow(color: Color.black.opacity(0.3),radius: 20,x: 0.0,y: 0.0)

ScrollView 从 HomeView 的顶部开始。

Tab view showing correctly,but not scrollview

ScrollView showing correctly,but not tab view

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)