这是我的代码,我尝试将NavigationLinks用作某种菜单:
struct ContentView: View {
init() {
UITableView.appearance().tableFooterView = UIView()
}
var body: some View {
NavigationView {
List {
NavigationLink(destination: Text("Test")) {
Text("Link A")
}
NavigationLink(destination: Text("Test")) {
Text("Link B")
}
NavigationLink(destination: Text("Test")) {
Text("Link C")
}
Text("Footer content here")
}
}
}
}
是否可以删除最底部一项上的Divider
,即位于“内容在这里”下方的行?
答案 0 :(得分:1)
这是可能的解决方案。使用Xcode 11.4 / iOS 13.4进行了测试
extension View {
func listRowUpperSeparator() -> some View {
self.listRowBackground(
VStack {
Divider().padding(.leading)
Spacer()
})
}
}
struct ContentView: View {
init() {
UITableView.appearance().separatorStyle = .none
}
var body: some View {
NavigationView {
List {
NavigationLink(destination: Text("Test")) {
Text("Link A")
}.listRowUpperSeparator()
NavigationLink(destination: Text("Test")) {
Text("Link B")
}.listRowUpperSeparator()
NavigationLink(destination: Text("Test")) {
Text("Link C")
}.listRowUpperSeparator()
Text("Footer content here")
.listRowUpperSeparator()
}
}
}
}