我正在尝试使用List在SwiftUI中创建SibeBarList, 我的代码:
import SwiftUI
struct DetailView: View {
let text: String
var body: some View {
Text(text)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
struct ContentView: View {
private let names = ["Homer", "Marge", "Bart", "Lisa"]
@State private var selection: String?
var body: some View {
NavigationView {
List(selection: $selection) {
Section(header: Text("The Simpsons")) {
ForEach(names, id: \.self) { name in
NavigationLink(destination: DetailView(text: name)) {
Text(name)
}
}
}
}.listStyle(SidebarListStyle())
DetailView(text: "Make a selection")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
有人可以帮我从列表中删除此滚动条吗?
macOS:10.15.6 Xcode:12.0 斯威夫特:5.3