I added a button and there was a syntax error

import SwiftUI

struct Calculate: View {
@State private var Salary = ""
@State private var Assets = ""
@State private var Liabilities = ""

var body: some View {
  
    NavigationView {
        VStack {
            TextField("Your Salary", text: $Salary)
                  .keyboardType(.numberPad)
                .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding(EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10))
                .background(Color.white)
                .clipShape(RoundedRectangle(cornerRadius: 8))
      .padding(.bottom, 10.0)
            
            TextField("Your Assets", text: $Assets)
                  .keyboardType(.numberPad)
                .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding(EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10))
                .background(Color.white)
                .clipShape(RoundedRectangle(cornerRadius: 8))
                .padding(.bottom, -25)
            
               .padding(.bottom, 35.0)

                TextField("Your Liabilities", text: $Liabilities)
                      .keyboardType(.numberPad)
                    .textFieldStyle(RoundedBorderTextFieldStyle())
    .padding(EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10))
        .background(Color.white)
        .clipShape(RoundedRectangle(cornerRadius: 8))
        .padding(.bottom, 0)
           
     
         

            Button(action: {
                print("HellowOrld")
            }) {
                Text(/*@START_MENU_TOKEN@*/"Button"/*@END_MENU_TOKEN@*/)
            }

       .cornerRadius(5)
                   font(.headline)
        .padding(.all, 15.0)
    
        .background(Color.init(red: 50/255, green: 50/255, blue:50/255))
            
        .offset(x: 0, y: -80)
        
       
    }
}
}

}

struct Calculate_Previews: PreviewProvider {
static var previews: some View {
Calculate()
}

}

I can't preview the file

Does it give you a diagnostic message?

EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

Your font line is missing a '.', I think that's why it's confused. Once I put that in it worked for me.

1 Like

thank you!

1 Like
Terms of Service

Privacy Policy

Cookie Policy