gpt4 book ai didi

SwiftUI 问题 : Place text underneath(outside) of list view

转载 作者:行者123 更新时间:2023-12-05 05:02:06 26 4
gpt4 key购买 nike

我试图将此信息放在我的列表下方。我不希望它包含在列表中,而是应该显示在 View 背景上。有点像 iOS 6 中的旧设置。我试过将我的代码片段放在不同的位置并删除堆栈,甚至更改我正在使用的堆栈,但我无法弄清楚。这是我的代码,我附上了截图 /image/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

}

}

最佳答案

您正在寻找的是页脚。 Section View将 Footer 作为 ViewBuilder 作为参数。

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

您可以传递 Text() 或创建您自己的自定义 View 。

关于SwiftUI 问题 : Place text underneath(outside) of list view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62377566/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com