【问题标题】:Stopping Navigation Controller? from Appearing When Scrolling to the Bottom停止导航控制器?从滚动到底部时出现
【发布时间】:2020-06-19 10:47:39
【问题描述】:

ScrollViewVStack 内部有四个水平堆栈 (HStack)。我在每个水平堆栈 (HStack) 中有一对 ZStack 东西。以下是我的代码。

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            ScrollView {
                VStack(spacing: 0) {
                    HStack(spacing: 0) {
                        ZStack {
                            Rectangle().frame(width: UIScreen.screenWidth / 2.0, height: UIScreen.screenWidth / 2.0, alignment: .topLeading)
                                .foregroundColor(.orange)
                                .border(Color.yellow, width: 2)
                            NavigationLink(destination: AliceView()) {
                                Text("Alice")
                                    .foregroundColor(Color.black)
                                    .font(.largeTitle)
                            }
                        }
                        ZStack {
                            Rectangle().frame(width: UIScreen.screenWidth / 2.0, height: UIScreen.screenWidth / 2.0, alignment: .topLeading)
                                .foregroundColor(.orange)
                                .border(Color.yellow, width: 2)
                            NavigationLink(destination: KimView()) {
                                Text("Kim")
                                    .foregroundColor(Color.black)
                                    .font(.largeTitle)
                            }
                        }
                    }

                    HStack(spacing: 0) {
                        ...
                        ...
                        ...
                    }

                    HStack(spacing: 0) {
                        ...
                        ...
                        ...
                    }

                    HStack(spacing: 0) {
                        ...
                        ...
                        ...
                    }
                }
            }
            .edgesIgnoringSafeArea(.all)
            .statusBar(hidden: true)
            .navigationBarTitle("")
        }
    }
}

当我滚动到顶部时,屏幕顶部没有显示任何内容。但是当我滚动到底部时,会出现一个看起来像导航控制器的水平条。如何阻止看起来像导航控件的水平条出现?谢谢。

【问题讨论】:

    标签: ios swiftui scrollview vstack hstack


    【解决方案1】:

    你需要隐藏导航栏

    .navigationBarTitle("")
    .navigationBarHidden(true)    // << add this !!
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-04
      • 2020-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多