I tried adding a NavigationLink without a NavigationView on another project and it worked.
However when I tried copy and pasting the code onto another project, it doesn't work.
Please help. I've tried testing it on an empty project and it doesn't work as well. I'm wondering what went wrong. I've checked the curly braces placement as well. All placed correctly...
import SwiftUI
struct Intro: View {
var body: some View {
ZStack {
VStack {
Image("CDM")
.resizable()
.frame(width: 500, height: 500, alignment: .center)
HStack {
Text("Welcome to Chatter")
.font(.system(size: 45, weight: .semibold, design: .rounded))
.foregroundColor(Color("Yellow"))
Image(systemName: "message.fill")
.font(.system(size: 45))
.foregroundColor(Color("Yellow"))
.padding()
}
Text("""
Note:
This experience is best viewed in Horizontal
""")
.font(.system(size: 30, weight: .semibold, design: .rounded))
.foregroundColor(.secondary)
.padding()
Button(action: {
print("intro2")
}) {
NavigationLink(destination: Intro2()) {
Text("Next")
.font(.system(size: 30, weight: .semibold ,design: .rounded))
.foregroundColor(.white)
.padding()
.background(Color("Purple"))
.cornerRadius(20)
}
}
}
}
}
}
struct Intro2: View {
var body: some View {
VStack {
Text("What you can do in this experience")
Button {
print("test")
} label: {
NavigationLink(destination: Main()) {
HStack {
Text("Click here to get started!")
.font(.system(size: 25, weight: .regular ,design: .rounded))
.foregroundColor(.white)
.padding()
.background(Color("Purple"))
.cornerRadius(20)
}
}
}
}
}
}