视图中的 NavigationLink 呈现为叠加层。斯威夫特用户界面
NavigationLink within view presented as an overlay. SwiftUI
我将一个视图呈现为叠加层,但是当我将带有目的地的 NavigationLink 添加到该叠加层视图时,文本显示为灰色并且点击它没有任何反应。我该如何进行?
struct ContentView: View {
var body: some View {
NavigationView { }
.overlay(
VStack {
NavigationLink(destination: Text("Go to some view")) {
Text("NavigationLink in overlay")
}
Button {
print("button tapped")
} label: {
Text("Button in overlay")
}
}
)
}
}
您的 NavigationLink 不在 NavigationView 中!试试这个:
struct ContentView: View {
var body: some View {
NavigationView {
Color.clear
.overlay(
VStack {
NavigationLink(destination: Text("Go to some view")) {
Text("NavigationLink in overlay")
}
Button {
print("button tapped")
} label: {
Text("Button in overlay")
}
}
)
}
}
}
我将一个视图呈现为叠加层,但是当我将带有目的地的 NavigationLink 添加到该叠加层视图时,文本显示为灰色并且点击它没有任何反应。我该如何进行?
struct ContentView: View {
var body: some View {
NavigationView { }
.overlay(
VStack {
NavigationLink(destination: Text("Go to some view")) {
Text("NavigationLink in overlay")
}
Button {
print("button tapped")
} label: {
Text("Button in overlay")
}
}
)
}
}
您的 NavigationLink 不在 NavigationView 中!试试这个:
struct ContentView: View {
var body: some View {
NavigationView {
Color.clear
.overlay(
VStack {
NavigationLink(destination: Text("Go to some view")) {
Text("NavigationLink in overlay")
}
Button {
print("button tapped")
} label: {
Text("Button in overlay")
}
}
)
}
}
}