Home > OS >  How do I make another series of buttons appear in SwiftUI
How do I make another series of buttons appear in SwiftUI

Time:07-18

My code currently asks the user to pick between Morning and Evening, and depending on their answer, it'll present two more options. However, the options presented after Morning/Evening question aren't functional. I would like my code to extend the quiz so that, for example, after pressing Evening, then pressing Savory, the code will present Option 1 and Option 2. Here is my current code:

import SwiftUI

struct IfElseQuiz: View {
    
@State var isMorning = false
@State var isEvening = false
@State var isSnack = false
@State var isMeal = false
@State var isSavory = false
@State var isSweet = false

    
    
var body: some View {
    VStack {
        ZStack {
            if !isMorning && !isEvening {
                HStack {
                    Button  {
                        isMorning.toggle()
                    } label: {
                        Text("Morning           
  • Related