Code below:
NavigationView{
ZStack{
Color("SmokyBlack").ignoresSafeArea()
VStack{
//ModularContent(titleName: titleName, subtitleText: subtitleText, imageName: imageName)
NavigationLink(destination: SecondOnboardingView()){
OnboardingButton(buttonText: btnName, updateOnboarding: false)
}
}
}// parent vstack
.preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/)
.navigationBarHidden(true)
} //nav view ends
My Issue: https://imgur.com/a/ALBdEBs
The button is clearly being pressed but nothing is happening
edit: code for the button. I have tried changing this button to plain text but it still doesn't work.
struct OnboardingButton: View {
var buttonText: String
var updateOnboarding: Bool
@AppStorage("onboardingCheck") var onboardingCheck: Bool?
var body: some View {
Button(action: {onboardingCheck=updateOnboarding},
label: {
ZStack{
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.white)
.frame(width: 300, height: 60, alignment: .center)
Text(buttonText)
.foregroundColor(.black)
.font(.system(size: 20))
.fontWeight(.semibold)
}
})
}
}
I seem to have figured out why.
Button(action: {onboardingCheck=updateOnboarding},
from OnboardingButton seems to only accept true as an answer to continue. To work around this, I simply made a different file that does not use Button() but instead the following:
struct OnboardingButtonTwo: View {
var buttonText: String
var body: some View {
ZStack{
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.white)
.frame(width: 300, height: 60, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
Text(buttonText)
.foregroundColor(.black)
.font(.system(size: 20))
.fontWeight(.semibold)
}
.padding(.bottom, 10)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.