'NavigationLink not working properly(SwiftUI)
My intention is to move to the next screen once I click the log in button or the get started button. If I click on them currently it just displays the view in a smaller window while leaving the background image on screen. I am fairly new to coding so I'm sure its a simple mistake but any help would be greatly appreciated. Here is the code I currently have:
struct StartingPage: View {
var body: some View {
ZStack {
Image("Blackhair")
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(height: 510, alignment: .bottomLeading)
}
VStack {
HStack {
Text("Welcome to")
.fontWeight(.bold)
.font(.title)
.background()
.frame(alignment: .topLeading)
Text("Redacted")
.fontWeight(.bold)
.foregroundColor(Color("600"))
.font(.title)
.background()
}
Text("A safe & relaxing place after a day of work")
.font(.title2)
.frame(alignment: .leading)
HStack {
FirstButton(text: "Log In")
SecondButton(text: "Get Started")
}
}
}
}
And my buttons are setup like this:
struct FirstButton: View {
var text: String
var body: some View {
NavigationView {
NavigationLink(destination: LogInScreen(), label: {
Text(text)
.fontWeight(.bold)
.font(.title2)
.frame(width: 100, height: 50, alignment: .center)
.background(Color.white)
.foregroundColor(Color("600"))
.buttonStyle(.borderedProminent)
.border(Color("600"))
.cornerRadius(10)
.buttonBorderShape(.roundedRectangle)
.padding()
})
}
}
}//End of struct
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
