SwiftUI 问题:将文本置于列表视图下方(外部)

SwiftUI Question: Place text underneath(outside) of list view

我正在尝试将此信息放在我的列表下方。我不希望它包含在列表中,而是应该显示在视图背景上。有点像 iOS 中的旧设置 6. 我试过将我的代码片段放在不同的位置并删除堆栈,甚至更改我正在使用的堆栈,但我无法弄清楚。这是我的代码,我附上了截图 https://i.stack.imgur.com/PcUgJ.png 以供参考。感谢任何可以帮助我的菜鸟自我的人。

我的代码:

import SwiftUI

struct SettingsAboutView: View {

    var body: some View {

         List{

            //Top Section
                Section {

                    HStack(spacing: 30) {

                    Spacer()

                            ZStack {

                                Rectangle()
                                    .frame(width: 50, height: 50)
                                    .clipShape(Rectangle())
                                    .shadow(radius: 2)
                                    .foregroundColor(Color("PineGlade"))

                                Image(systemName: "leaf.arrow.circlepath")
                                    .resizable()
                                    .frame(width: 25, height: 25)
                                    .clipShape(Rectangle())
                                    .foregroundColor(.white)


                            }.cornerRadius(10)

                            VStack(alignment: .leading) {

                                Text("Gardn")
                                    .font(.system(size: 32))
                                    .fontWeight(.bold)
                                    .foregroundColor(Color("ShipsOfficer"))



                                Text("OnlyOdds.co Labs")
                                    .font(.system(size: 13))
                                    .fontWeight(.medium)
                                    .foregroundColor(Color("ShipsOfficer"))

                            }

                    Spacer()

                    }.padding()

                    NavigationLink(destination: SettingsPrivacyView()) {

                            Button(action: {

                                print("Privacy Settings")

                            }) {

                                    SettingsCell(title: "Privacy", imgName: "eye.slash", clr: Color("PineGlade"))

                               }

                    }

                    NavigationLink(destination: SettingsNotificationsView()) {

                            Button(action: {

                                print("Notification Settings")

                            }) {

                                    SettingsCell(title: "Notifications", imgName: "bell", clr: Color("PineGlade"))

                                }

                    }

                }

            //Technical Info
                HStack(spacing: 62) {

                    Spacer()

                    Text("V \(UIApplication.appVersion!)")
                            .font(.system(size: 14))
                            .fontWeight(.light)
                            .foregroundColor(Color("ShipsOfficer"))
                            .opacity(0.5)


                        Text("Build  \(UIApplication.appBuild!)")
                            .font(.system(size: 14))
                            .fontWeight(.light)
                            .foregroundColor(Color("ShipsOfficer"))
                            .opacity(0.5)

                    Spacer()

                }

         }.listStyle(GroupedListStyle())
         .environment(\.horizontalSizeClass, .regular)
         .navigationBarTitle("Settings", displayMode: .inline)

    }

}

struct SettingsAboutView_Previews: PreviewProvider {

    static var previews: some View {

        SettingsAboutView()
    }

}

extension UIApplication {

    static var appVersion: String? {

        return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String

    }

}

extension UIApplication {

    static var appBuild: String? {

        return Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String

    }

}

把List放到一个VStack里然后放 文本(您的文本)

榜单下

您要查找的是页脚。 Section View 将 Footer 作为 ViewBuilder 作为参数。

Section(footer: Text("Your footer text")) {
    //Your Content here
}

您可以通过 Text() 或创建您自己的自定义视图。