我正在尝试将项目列表添加到视图中,同时上面有一个图标。目前,当我构建我的代码时,它将图标和列表分开,这是我正在寻找的,但它使图标静态且列表可滚动。我希望图标和列表一起移动。
let items = ["Text", "Text", "Text", "Text"]
struct SignInView: View {
var body: some View {
NavigationView {
VStack {
Image(systemName: "car.fill")
.font(.system(size: 40))
.foregroundColor(.blue)
.frame(width: 150, height: 150)
List {
ForEach(items, id: \.self) { item in
HStack {
Image(systemName: "house.fill")
.foregroundColor(.blue)
Text(item)
Spacer ()
Text("1")
Image(systemName: "chevron.forward")
.foregroundColor(.blue)
}
}
}
}
}.navigationBarTitle("Car", displayMode: .inline)
}
}