SwiftUI问题:如何在列表视图下方(外部)放置文本

3
我试图将这些信息放置在我的列表下方。我不想将它包含在列表中,而是应该显示在视图背景上。就像iOS 6中的旧设置一样。我尝试过将代码片段放在不同的位置,并删除了stacks甚至更改了我使用的stacks,但是我无法弄清楚。以下是我的代码和我附加的截图以供参考。感谢任何能帮助我这个新手的人。
我的代码:
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

    }

}

你尝试过将“版本单元格”的背景颜色更改为类似于不存在的颜色吗? - Mojtaba Hosseini
2个回答

4
你需要查找的是“页脚(footer)”内容。在Section View中,Footer作为ViewBuilder参数被使用。
Section(footer: Text("Your footer text")) {
    //Your Content here
}

你可以传递 Text() 或创建自己的自定义视图。

谢谢!这正是我需要的!我知道它很简单,但就是想不出来。 - PoonDopolis
@PoonDopolis 没问题。我也不得不阅读他们的文档,以前只知道它是由Objective C时代遗留下来的,从未为SwiftUI查询过。 - davidev

-1
只需将List放入VStack中,然后在列表下方添加Text(yourtext)即可。

我尝试过了,但是我的导航栏标题一直出现错误。 - PoonDopolis
当以这种方式放置文本时,文本不会显示。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接