Is there a way to put a view in the list header without sections? The table views normally have a property called tableHeaderView
which is a header for the whole table and has nothing to do with section headers.
I'm trying to have a list and be able to scroll it like tableHeaderView
from UITableView
.
struct MyView: View {
let myList: [String] = ["1", "2", "3"]
var body: some View {
VStack {
MyHeader()
List(myList, id: \.self) { element in
Text(element)
}
}
}
}
Thanks to Asperi. This is my final solution for the table header.
struct MyHeader: View {
var body: some View {
Text("Header")
}
}
struct DemoTableHeader: View {
let myList: [String] = ["1", "2", "3"]
var body: some View {
List {
MyHeader()
ForEach(myList, id: \.self) { element in
Text(element)
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With