try the following, It gets rid of the layout constraint issues and shows the My Text Label, using an EmptyView as the destination and the help button in the navbar. There is a certain view hierarchy that must be kept to avoid layout issues.
struct ContentView: View {
@State var selection: String?
let id = "1"
var body: some View {
test
}
var test: some View {
NavigationView {
NavigationLink(tag: id, selection: $selection) {
EmptyView()
.navigationTitle("Welcome")
} label: {
Text("My Test")
}
.toolbar {
Button("Help") {
print("Help tapped!")
}
}
}
}
Example two without the NavigationLink
struct ContentView: View {
var body: some View {
nonavLink
}
var nonavLink: some View {
NavigationView {
Text("My Test")
.toolbar {
Button("Help") {
print("Help tapped!")
}
}
}
.navigationTitle("Welcome")
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: