如何在NavigationLink
标题和箭头/披露指示符之间添加文本,如下左图所示?
SwiftUI 代码:
struct NavigationStackTest: View {
let fruits = ["Orange", "Apple"]
var body: some View {
NavigationStack{
VStack{
List(fruits, id:\.self){ fruit in
HStack{
//Text("Details")
NavigationLink(fruit, value: fruit)
Text("Details")
}
}
.navigationDestination(for: String.self) { item in
Text(verbatim: item)
}
}
}
}
}
现在,您只需将
String
标签传递给NavigationLink
. 相反,您可以传递 aView
并使用HStack
andSpacer
来布局您的内容: