Need button help

I am trying to add a button but with the image that I have, it’s not showing it except for when I get rid of the image. Can someone please help me out

Here is what the code look like

Hi @kiki21a

You can use the version of mine try to play with it a little to understand what’s the code is all about. You can also compare it with you work.

struct ContentView: View {
  var body: some View {
    
    ZStack {
      Image("birthday")
        .resizable()
        .edgesIgnoringSafeArea(.all)
        .aspectRatio(contentMode: .fill)
      
      VStack(alignment: .center) {
        Text("Sample message")
          .font(.title)
          .fontWeight(.bold)
          .foregroundColor(.white)
          .multilineTextAlignment(.center)
          .shadow(radius: 2)
          .padding(.bottom)
        
    
        Button("Sample Button") { }
        .font(.title)
        .shadow(radius: 2)
      }
    }
  }
}

I intentionally leave the code here without explanation, maybe you can explain what you understand at the comment below? Good luck! :blush:

Note:
You can also put your code inside a pair of ``` in order for others to just copy and paste your code just like this.

Thank you so much! It worked!!

This is my screen, I had to fix something last night, and when I tried it again. The button isn’t on the phone screen, it’s at the bottom when it’s supposed to be near the bottom of the phone screen . How can I fix that
"
import SwiftUI

struct ContentView: View {
var body: some View {

    ZStack {
        Image("birthday")
            .edgesIgnoringSafeArea(.all)
            .aspectRatio(contentMode: .fit)

        VStack(alignment: .center) {
            Spacer()
            Text("Welcome to Smilon!!")
                .font(.largeTitle)
                .fontWeight(.bold)
                .foregroundColor(Color.black)
                .multilineTextAlignment(.center)
              
            Spacer()
            
            Button("Next") {}
            .font(.title)
            .shadow(radius: 2)

"

Is this what you want to see (bearing in mind that the image is slightly different)?

Code:

struct ContentView: View {
    var body: some View {
        ZStack {
            Image("birthday")
                .resizable()
                .scaledToFit()
                .edgesIgnoringSafeArea(.all)

            VStack(alignment: .center) {
                Spacer()
                Text("Welcome to Smilon!!")
                    .font(.largeTitle)
                    .fontWeight(.bold)
                    .foregroundColor(Color.black)
                    .multilineTextAlignment(.center)

                Spacer()

                Button("Next") {

                }
                .font(.title)
                .shadow(radius: 2)
            }
        }
    }
}
1 Like